Skip to content

fix: update status to idle immediately after scan completes#6

Merged
chodeus merged 1 commit intomainfrom
claude/fix-scanning-status-display-4PvZm
Apr 14, 2026
Merged

fix: update status to idle immediately after scan completes#6
chodeus merged 1 commit intomainfrom
claude/fix-scanning-status-display-4PvZm

Conversation

@chodeus
Copy link
Copy Markdown
Owner

@chodeus chodeus commented Apr 14, 2026

Summary

  • Fix status stuck on "scanning" after scan completes: Move _webui_update(status="idle") to immediately after run_scan() returns, before run_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.
  • Add crash protection to main loop: Wrap run_scan() and run_auto_delete() in try/except so unhandled exceptions (e.g. from Lidarr API calls in _finalize_scan) don't kill the main loop and leave the WebUI permanently stuck.
  • Fix corrupt.txt truncation risk: Use atomic write (temp file + rename) in _finalize_scan() so a crash between truncating and rewriting can't leave corrupt.txt empty — which caused the Corrupt Files page to show 0 files.
  • Show "Finalizing..." at 100%: Display "Finalizing..." instead of "Calculating..." when scan progress reaches 100% but status hasn't transitioned yet.

Test plan

  • Run a full scan and verify the dashboard transitions to "Idle" immediately when the scan finishes (before auto-delete runs)
  • Verify the Corrupt Files page shows the correct count after scan completion
  • Verify the dashboard summary (corrupt count, last scan time) updates after scan
  • Confirm that if _finalize_scan encounters an error, the main loop recovers and status returns to "idle"
  • Check that "Finalizing..." appears briefly at 100% instead of "Calculating..."

https://claude.ai/code/session_01WNj5Uaar1MGd2kJq9DeAhn

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
@chodeus chodeus merged commit 7907c5d into main Apr 14, 2026
3 of 4 checks passed
@chodeus chodeus deleted the claude/fix-scanning-status-display-4PvZm branch April 14, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants