fix(download): resume state warnings, cancel on failure, zero-size SplitChunks #165

Merged
fuzzy merged 1 commit from feature/fix-bugs-143-138-128-140-131 into main 2026-07-15 17:23:33 +00:00
Owner

What

Fixes 3 issues, closes 2 already-done ones. All in one PR.

#143 — SaveResumeState failures silently lost

_ = SaveResumeState(...) now logs a warning on error. Download continues,
but the user gets visibility if resume state can't be saved.

#140 — Workers keep running after first failure

Added context.WithCancel(ctx) wrapping. When the first chunk error is
received, cancel() is called — in-flight workers abort immediately
instead of exhausting retries.

#131 — SplitChunks produces invalid Range for zero-size files

SplitChunks(0, n) now returns nil. Download() checks for empty
chunks and returns early (no-op for zero-size files).

#138 / #128 — Already handled

  • #138 (single-threaded fallback with unknown content-length): already
    fixed by the fullDownload=true path using io.Copy (reads to EOF)
  • #128 (store user agent on Client): already implemented in PR #127

Testing

  • go test -race ./... — all pass, no races
  • golangci-lint run — 0 issues
  • go build ./..., go vet ./... — all clean

Breaking Changes

None

Closes #143, #140, #131, #138, #128

## What Fixes 3 issues, closes 2 already-done ones. All in one PR. ### #143 — SaveResumeState failures silently lost `_ = SaveResumeState(...)` now logs a warning on error. Download continues, but the user gets visibility if resume state can't be saved. ### #140 — Workers keep running after first failure Added `context.WithCancel(ctx)` wrapping. When the first chunk error is received, `cancel()` is called — in-flight workers abort immediately instead of exhausting retries. ### #131 — SplitChunks produces invalid Range for zero-size files `SplitChunks(0, n)` now returns `nil`. Download() checks for empty chunks and returns early (no-op for zero-size files). ### #138 / #128 — Already handled - #138 (single-threaded fallback with unknown content-length): already fixed by the `fullDownload=true` path using `io.Copy` (reads to EOF) - #128 (store user agent on Client): already implemented in PR #127 ## Testing - [x] `go test -race ./...` — all pass, no races - [x] `golangci-lint run` — 0 issues - [x] `go build ./...`, `go vet ./...` — all clean ## Breaking Changes None Closes #143, #140, #131, #138, #128
fix(download): multiple bug fixes
All checks were successful
Test and Release / test (pull_request) Successful in 5m1s
Test and Release / lint (pull_request) Successful in 7m20s
49f3da8f73
- #143: log warning when SaveResumeState fails instead of silent discard
- #140: cancel context on first worker failure to stop remaining workers
- #131: SplitChunks returns nil for zero-size files (was returning [{0,0}])
- #138: already handled (fullDownload=true path uses io.Copy)
- #128: already implemented (Client stores userAgent field)

Closes #143, #140, #131, #138, #128
the.auditor left a comment

Review: APPROVED

Verification

  • go vet ./... passes
  • go build ./... passes
  • go test -race ./... all pass

Fixes applied

Issue Fix
#143 SaveResumeState errors now log a warning instead of silent discard
#140 context.WithCancel wrapping; cancel() called on first chunk error
#131 SplitChunks(fileSize<=0) returns nil; Download() checks for empty chunks and exits cleanly
#138 Already fixed (fullDownload + io.Copy path)
#128 Already fixed (userAgent stored on Client)

Closes #128, #131, #138, #140, #143 on merge.

## Review: APPROVED ### Verification - `go vet ./...` — ✅ passes - `go build ./...` — ✅ passes - `go test -race ./...` — ✅ all pass ### Fixes applied | Issue | Fix | |-------|-----| | #143 | `SaveResumeState` errors now log a warning instead of silent discard | | #140 | `context.WithCancel` wrapping; `cancel()` called on first chunk error | | #131 | `SplitChunks(fileSize<=0)` returns nil; `Download()` checks for empty chunks and exits cleanly | | #138 | Already fixed (fullDownload + io.Copy path) | | #128 | Already fixed (userAgent stored on Client) | Closes #128, #131, #138, #140, #143 on merge.
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-15 17:18:28 +00:00
fuzzy merged commit 49f3da8f73 into main 2026-07-15 17:23:33 +00:00
fuzzy deleted branch feature/fix-bugs-143-138-128-140-131 2026-07-15 17:23:33 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/pget!165
No description provided.