Skip to content

Commit

Permalink
fix: reuse length check (#3432)
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <majinjing3@gmail.com>
  • Loading branch information
jim3ma authored Aug 13, 2024
1 parent 584b67d commit 22913db
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/daemon/peer/peertask_reuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ func (ptm *peerTaskManager) storePartialFile(ctx context.Context, request *FileT
return nil
}

func noRangeEnd(rg string) bool {
return strings.HasSuffix(rg, "-")
func hasRangeEnd(rg string) bool {
return !strings.HasSuffix(rg, "-")
}

func (ptm *peerTaskManager) tryReuseStreamPeerTask(ctx context.Context, taskID string,
Expand Down Expand Up @@ -335,7 +335,7 @@ func (ptm *peerTaskManager) tryReuseStreamPeerTask(ctx context.Context, taskID s
} else if request.Range != nil {
// the length is from reuse task, ensure it equal with request
// skip check no range end case
if length != request.Range.Length && noRangeEnd(request.URLMeta.Range) {
if length != request.Range.Length && hasRangeEnd(request.URLMeta.Range) {
log.Errorf("target task length %d did not match range length %d", length, request.Range.Length)
return nil, nil, false
}
Expand Down

0 comments on commit 22913db

Please sign in to comment.