fix: update status to idle immediately after scan completes#6
Merged
Conversation
The scan status was stuck on "scanning" after completion because the status update to "idle" only happened after run_auto_delete() finished (or if the main loop crashed from an unhandled exception). This also caused the corrupt files page to show 0 files and the dashboard to display stale summary data. Three fixes: - Move _webui_update(status="idle") to right after run_scan() returns, before auto-delete runs - Wrap run_scan() and run_auto_delete() in try/except so unhandled exceptions don't crash the main loop and leave status stuck - Use atomic write (tmp + rename) for corrupt.txt in _finalize_scan() to prevent truncation if the function crashes mid-write - Show "Finalizing..." instead of "Calculating..." when scan is at 100% https://claude.ai/code/session_01WNj5Uaar1MGd2kJq9DeAhn
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
_webui_update(status="idle")to immediately afterrun_scan()returns, beforerun_auto_delete()runs. Previously, if auto-delete took a long time or the main loop crashed from an unhandled exception, the UI would stay stuck on "scanning" forever.run_scan()andrun_auto_delete()intry/exceptso unhandled exceptions (e.g. from Lidarr API calls in_finalize_scan) don't kill the main loop and leave the WebUI permanently stuck._finalize_scan()so a crash between truncating and rewriting can't leavecorrupt.txtempty — which caused the Corrupt Files page to show 0 files.Test plan
_finalize_scanencounters an error, the main loop recovers and status returns to "idle"https://claude.ai/code/session_01WNj5Uaar1MGd2kJq9DeAhn