Repository navigation
fix(download): finalize completed range resumes - #9432
Conversation
lstein
left a comment
There was a problem hiding this comment.
Thanks for the fix — this is exactly the right shape: the missing rename was the whole bug, and promoting the sidecar before signaling completion means on_complete consumers (including the model installer) now find a real file. I gave this an adversarial pass (traced every consumer of the new state, attacked the rename and the pause tail with interleavings, verified behavior empirically) and found no blockers. All 17 tests in the file pass locally, including your two new ones.
What I verified holds up:
- The mismatch→PAUSED path is coherent end to end: the job is still WAITING so
_signal_job_pausedfires,_cleanup_cancelled_jobskips paused jobs so the sidecar survives, andrestart_failed'sclear_partials=Truedeletes it — so "Restart required" genuinely restarts (no 416 loop). resume_from > 0always impliesjob.download_pathis set (all three resume branches guarantee it), so the rename can never target a directory via theor job.destarm.- The regex is safe against real-world 416 responses (S3/CloudFront/nginx/HF emit exactly
bytes */N;bytes */*correctly falls through to pause), and the worker'sstatus != COMPLETEDguard prevents double-completion.
One non-blocking suggestion inline: when the 416 carries no parseable Content-Range (a SHOULD in RFC 9110, not a MUST), a genuinely complete file now dead-ends in "Restart required" and gets fully re-downloaded. Falling back to the recorded expected_total_bytes/total_bytes (never resume_from) keeps your strictness while rescuing that case — suggestion plus two regression tests attached, validated locally.
Two pre-existing issues this PR surfaces but shouldn't have to fix (follow-up material):
- A marker-restored install whose first part pauses in this branch (before any started signal) leaves the install job's
download_partsempty, sorestart_failedno-ops (model_install_default.py:625) and the PAUSED marker rewrite persistsfiles: [], discarding resume metadata. - If the sidecar vanishes between the resume stat and the rename (they're a network round-trip apart), the raised
FileNotFoundErrormarks the part ERROR and the error callback rmtrees the whole install tmpdir, including other completed parts. Same exposure class as the pre-existing final rename.
Approving — the suggestion is optional polish, not a condition.
|
I'll wait a couple of days to see if you want to act on either of the two nits in the review above. If I don't hear from you one way or another, I'll go ahead and merge for inclusion in 6.14.0. |
today |
|
Implemented the headerless 416 fallback in 77f053b. It uses only the originally recorded expected size, never the resumed byte count; added coverage for both the recorded-size and unknown-size paths. The two broader install-resume issues remain suitable for follow-up work. |
Summary
.downloadingfile when HTTP 416 confirms the remote size.Closes #9431
Testing
uvx [email protected] check invokeai/app/services/download/download_default.py tests/app/services/download/test_download_queue.py