bug: v0.2.1 — upgrade cleanup, online-file races, instant exit#47
Merged
Conversation
Three bugs fixed in one patch: 1. Manual upgrade from 0.1.x left the old binary, autostart entry, and Apps & Features Uninstall key in place, and could deadlock the state.db migration when a v0.1.x process was still running. Adds cleanup_legacy_install() that runs before migrations: kills other immichsync.exe instances, removes legacy binaries at %APPDATA%\ImmichSync and %APPDATA%\bees-roadhouse\immichsync, and clears stale Run / Uninstall registry entries when they point at a legacy path. 2. SHA-1 hash and upload-stream code paths trusted the watcher's placeholder filter, but a file can be evicted to the cloud after the watcher sees it and before queue/worker reads it. Reading the placeholder hydrates the whole file from the cloud — pages of bandwidth and CPU for a file the watcher would skip on its next pass. Adds is_online_file re-checks at queue-time (in process_file between metadata fetch and hash) and worker-time (in process_item before opening the file). Worker marks the entry "failed" with a descriptive message; the watcher's reconciliation re-enqueues when the file becomes local again. 3. Tray Quit and WM_QUIT waited up to 3s on pipeline.stop()'s graceful shutdown of in-flight uploads, making the tray feel laggy on exit. Adds shutdown_and_exit() — signals the watch engine + upload worker to stop, then process::exit(0). In-flight "uploading" rows are already reset to "pending" by reset_stale_uploading on next launch, so nothing is lost. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Three upgrade/lifecycle bugs in one patch. Cargo bumped to 0.2.1.
1. Manual upgrade from 0.1.x left leftovers + could deadlock migration
The in-app updater rename-dances on the installed binary, but a user who downloads the new release manually from GitHub Releases (or upgrades across the 0.2.0 install-layout change) ran into:
%APPDATA%\ImmichSync\or%APPDATA%\bees-roadhouse\immichsync\.HKCU\...\Run\ImmichSyncautostart entry pointing at the old path → both 0.1.x and 0.2.x launch at next login.migrate_to_split_layouttried torenamean openstate.db→ silently fell back to copy →remove_filefailed → divergent DBs at old + new paths.Adds
cleanup_legacy_install()(called frommain()before the migrations) that:taskkill /F /FI 'PID ne <ours>' /IM immichsync.exeto release file locks.version.txt.2. SHA-1 hash + upload-stream hydrated cloud placeholders
The watcher's filter drops cloud-placeholder files at discovery, but a file can be evicted between watcher → queue or queue → worker (OneDrive / SeaDrive auto-evict under storage pressure). Reading the placeholder triggered a full cloud download — gigabytes of bandwidth + CPU for a file we were about to skip anyway.
The comment at
queue.rs:233-237explicitly relied on the watcher's filter being authoritative; it's not, race-wise.queue.rs:process_file:is_online_file(&meta)re-check betweenfs::metadataandhash_file. Skips withOk(None).worker.rs:process_item:is_online_filere-check after pickup, before opening the file for upload. Marks the entry"failed"with a recognizable message; the watcher's reconciliation re-enqueues when the file is local again.3. Tray Quit / WM_QUIT waited up to 3s
pipeline.stop()graceful path awaits the spawned per-item upload tasks (up to 3s). On user-initiated Quit that's a noticeable hang — "forget the current operation, drop it, exit."Adds
App::shutdown_and_exit() -> !:pipeline.signal_stop()— signals the worker but doesn't wait.std::process::exit(0).In-flight `"uploading"` rows are recovered by `reset_stale_uploading` on next launch (existing mechanism), so partial uploads retry cleanly. The graceful
shutdown()path is preserved for the RestartToUpdate flow (the new instance needs a clean handoff ofstate.db).Test plan