Skip to content

Commit

Permalink
fix: digest and range validation in v2 (#2892)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Nov 21, 2023
1 parent 11829e3 commit 18c28a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scheduler/service/service_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())}))
}

Expand Down

0 comments on commit 18c28a7

Please sign in to comment.