fix: reuse length check (#3432)

Signed-off-by: Jim Ma <majinjing3@gmail.com>
This commit is contained in:
Jim Ma 2024-08-13 20:59:57 +08:00 committed by GitHub
parent 584b67d571
commit 22913db39f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -227,8 +227,8 @@ func (ptm *peerTaskManager) storePartialFile(ctx context.Context, request *FileT
return nil return nil
} }
func noRangeEnd(rg string) bool { func hasRangeEnd(rg string) bool {
return strings.HasSuffix(rg, "-") return !strings.HasSuffix(rg, "-")
} }
func (ptm *peerTaskManager) tryReuseStreamPeerTask(ctx context.Context, taskID string, func (ptm *peerTaskManager) tryReuseStreamPeerTask(ctx context.Context, taskID string,
@ -335,7 +335,7 @@ func (ptm *peerTaskManager) tryReuseStreamPeerTask(ctx context.Context, taskID s
} else if request.Range != nil { } else if request.Range != nil {
// the length is from reuse task, ensure it equal with request // the length is from reuse task, ensure it equal with request
// skip check no range end case // 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) log.Errorf("target task length %d did not match range length %d", length, request.Range.Length)
return nil, nil, false return nil, nil, false
} }