fix(model-install): preserve install tmpdir when a single multi-file part fails - #9591
lorenzozanee wants to merge 1 commit into
Conversation
JPPhoto
left a comment
There was a problem hiding this comment.
@lorenzozanee Thanks for this PR. I'd like you to address the following findings/issues and then re-request review from me:
-
invokeai/app/services/model_install/model_install_default.py:1525: Auto-pausing writes no model-install event; frontend only logsdownload_error, so UI remainsdownloadingwith no recovery action. Effect: stale UI. Likelihood: normal multi-file 5xx failure. Recovery: manual refresh/reconnect. Test: assert client state changes topausedwithout refetch. -
invokeai/app/services/model_install/model_install_default.py:1525: After restart, an early resumed-part failure can overwrite the marker with emptyfilesbecauseinstall_job.download_partsis empty. ETag/Last-Modified are lost; the nextRangerequest lacksIf-Rangeand can silently append bytes from changed remote content. Effect: possible corrupt model. Likelihood: plausible after restart with an existing partial. Recovery: delete partial and reinstall. Test: restore paused marker with partial plus ETag, fail before_download_started_callback, then verify metadata survives andIf-Rangeis sent. -
docs/src/content/docs/development/Architecture/model-manager.mdx:650: Docs still claim model installs never preserve partial downloads, now false. Effect: inaccurate recovery/storage guidance. Likelihood: normal recoverable multi-file failure. Recovery: update docs. Test: docs check must remove that claim.
Suggestions:
- Consider copying parent download parts into the install job before writing the paused marker.
- Consider emitting and handling a dedicated model-install paused event.
Summary
A single part error in a multi-file install deletes the entire install tmpdir. A transient failure on one file (an HTTP 5xx, or the sidecar rename race from #9432) discards parts that already completed and
.downloadingpartials holding resumable progress, so the next attempt restarts the whole install from zero.The error path now preserves the tmpdir when it contains anything worth keeping (a completed part file or a non-empty partial): the install is marked paused and the install marker is persisted, so restarting failed files and resume can pick up where the download left off. When nothing on disk is worth keeping, the tmpdir is still removed as before.
Related Issues / Discussions
Closes #9481
QA Instructions
New regression test (fails on the previous HEAD, passes with this change):
Surrounding suites and lint:
Result: 52 passed (35 model install, 17 download queue), ruff clean.
Merge Plan
Standard merge.
Checklist
What's Newcopy (if doing a release after this PR)Supersedes #9488(原PR分支已删,按原提交重建)