fix(download): single-threaded fallback produces empty file when Content-Length unknown #138
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/pget#138
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
internal/downloader/download.go:162-172— When server doesn't provideContent-Length,fileSizestays 0.SplitChunks(0, 1)returns[{Start: 0, End: 0}], andrunWorkerdoesio.CopyN(ws, body, 0)— reads 0 bytes. Result: empty output file.This path triggers when:
The single-threaded fallback should download the entire file without Range headers and without a size limit. Suggestion:
And in
runWorker/downloadChunkHTTP, when chunk.End == math.MaxInt64, don't set Range header and useio.Copyinstead ofio.CopyN.Discovered during review of PR #137.
Closing — already handled. When fileSize <= 0 and parallel is false, fullDownload=true and runFullDownload uses io.Copy (reads until EOF) instead of io.CopyN with expected size.