From 18c28a7364c2db2fb59b844d45a817982dc39c32 Mon Sep 17 00:00:00 2001 From: Gaius Date: Tue, 21 Nov 2023 17:12:05 +0800 Subject: [PATCH] fix: digest and range validation in v2 (#2892) Signed-off-by: Gaius --- scheduler/service/service_v2.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scheduler/service/service_v2.go b/scheduler/service/service_v2.go index 7b7f967280a..2d1e704836c 100644 --- a/scheduler/service/service_v2.go +++ b/scheduler/service/service_v2.go @@ -1264,7 +1264,7 @@ func (v *V2) handleResource(ctx context.Context, stream schedulerv2.Scheduler_An task, loaded := v.resource.TaskManager().Load(taskID) if !loaded { options := []resource.TaskOption{resource.WithPieceLength(int32(download.GetPieceLength()))} - if download.Digest != nil { + if download.GetDigest() != "" { d, err := digest.Parse(download.GetDigest()) if err != nil { return nil, nil, nil, status.Error(codes.InvalidArgument, err.Error()) @@ -1287,7 +1287,7 @@ func (v *V2) handleResource(ctx context.Context, stream schedulerv2.Scheduler_An peer, loaded := v.resource.PeerManager().Load(peerID) if !loaded { options := []resource.PeerOption{resource.WithPriority(download.GetPriority()), resource.WithAnnouncePeerStream(stream)} - if download.Range != nil { + if download.GetRange() != nil { options = append(options, resource.WithRange(http.Range{Start: int64(download.Range.GetStart()), Length: int64(download.Range.GetLength())})) }