feat: report two-stage download progress to the *arr and logs - #37
Open
bugrax wants to merge 2 commits into
Open
feat: report two-stage download progress to the *arr and logs#37bugrax wants to merge 2 commits into
bugrax wants to merge 2 commits into
Conversation
put.io reports a transfer as 100% as soon as *its own* cloud download finishes, but putioarr still has to pull the files down to local disk. During that second stage the *arr saw a progress bar frozen at 0% (it was pinned there so it wouldn't import files that weren't on disk yet), so users couldn't tell a stuck download from one still making progress (issue wouterdebie#5). Track the bytes pulled to local disk per transfer with a lock-free AtomicU64 counter (incremented per streamed chunk, read only when the *arr polls or the status line is logged, so the download hot path is unaffected) and map the two stages onto a single 0-100% bar: - put.io cloud download -> 0-50% - local pull to disk -> 50-100% Both stages move the same number of bytes, so the split is byte-accurate. The transfer only reaches 100% once the files are actually on disk, so the existing import-safety behaviour (issue wouterdebie#16) is preserved. Orphaned watch-folder files (issue wouterdebie#34) have no cloud stage, so their local pull is reported directly as 0-100%. The periodic status log now prints the same combined percentage per transfer, e.g. `[abcd: Some.Movie] (73%)`.
There was a problem hiding this comment.
Pull request overview
This PR improves user-visible download progress reporting by combining put.io’s “cloud download” stage with putioarr’s “local pull to disk” stage into a single progress signal for *arr clients and periodic logs, while preserving the “don’t report complete until local files exist” safety behavior.
Changes:
- Add per-transfer local byte counters (
AtomicU64) in shared state, updated by download workers. - Map two-stage progress into a single 0–100% scale for
torrent-getresponses (including orphan watch-folder files). - Include the combined progress percentage in the periodic “Active transfers” log output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/state.rs |
Adds a per-transfer local byte counter map and accessors for tracking local pull progress. |
src/http/handlers.rs |
Computes and reports combined two-stage progress to *arr clients; prunes counters for absent transfers. |
src/download_system/transfer.rs |
Updates periodic status logging to include combined progress percent. |
src/download_system/orchestration.rs |
Clears per-transfer progress counters once a transfer is locally complete. |
src/download_system/download.rs |
Increments the per-transfer counter as streamed chunks are written; seeds from bytes already on disk. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ixes - handlers: keep a transfer in a downloading state (non-zero left_until_done) while the local pull is incomplete even when put.io reports no size, so a 0/0 transfer isn't read as finished and imported early (preserves wouterdebie#16). - handlers: only prune local-progress counters when the transfers listing succeeded; a transient list failure returns an empty set that would otherwise wipe progress for in-flight downloads. - download: track how many of a file's bytes are in the shared counter so a from-scratch restart (server ignoring the Range request, HTTP 200) removes its previous contribution instead of double-counting the re-downloaded bytes. - state: give local_byte_counter a read-lock fast path for the common case where the counter already exists, avoiding write-lock contention between download workers. - transfer: cap the logged percentage at 99 until local_complete flips, so the status line doesn't claim 100% while the pull is still active.
Contributor
Author
|
Thanks — all five addressed in 508147e:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #5.
put.io reports a transfer as 100% as soon as its own (cloud) download
finishes, but putioarr still has to pull the files down to local disk. During
that second stage the *arr showed a progress bar frozen at 0% — it was pinned
there so the *arr wouldn't try to import files that weren't on disk yet (#16) —
so users couldn't tell a stuck download from one still making progress.
What this does
Maps the two stages onto the single progress bar the *arr shows:
Both stages move the same number of bytes, so the 50/50 split is byte-accurate.
The transfer only reaches 100% once the files are actually on local disk, so the
import-safety behaviour from #16 is preserved. Orphaned watch-folder files (#34)
have no cloud stage, so their local pull is reported directly as 0–100%.
The periodic status log prints the same combined percentage per transfer:
Implementation
AtomicU64counter, incremented per streamed chunk in the download worker. It's read only
when the *arr polls (
torrent-get) or the status line is logged, so thedownload hot path is untouched — this avoids the slowdown that an earlier
byte-counting attempt hit (noted in Download progress updates in the console / log / sonarr / radarr #5).
pruned once a transfer completes or leaves the account, so the map stays
bounded.
Testing
Built and deployed to a live instance; verified the *arr progress bar now
advances continuously through both the cloud and local stages instead of
sitting at 0% during the local pull, and the status log shows the combined
percentage.