fix: wipe downloaded resources on COMPLETE rescan#3406
Merged
Conversation
A COMPLETE rescan never deleted previously downloaded asset files, and the post-scan download steps skip work when a file already exists (store_media_file) or when the source URL is unchanged (get_cover). This meant covers, screenshots, manuals, and SS/gamelist/LaunchBox extended media were reused even when a fresh fetch returned a different URL — defeating the region-priority fix in #3396. - scan socket: for a COMPLETE rescan of an existing ROM, remove the cover, manual, screenshots, and all extended media directories before re-fetching, so the download steps pull fresh files. - scan_handler: reset url_cover/url_screenshots/url_manual and the matching path_* fields for COMPLETE rescans before the priority loops run, so stale DB values are nulled when no selected source supplies them (clearing for deselected sources falls out as a subset). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes COMPLETE rescan behavior so previously downloaded artwork/media doesn’t get reused when metadata providers return updated URLs or when providers are deselected, ensuring “fresh” assets and clearing stale DB URL/path fields.
Changes:
- Reset artwork URL/path fields during COMPLETE rescans so stale values get cleared when no selected source provides them.
- Wipe on-disk downloaded artwork/media directories for existing ROMs during COMPLETE rescans to force re-fetching.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| backend/handler/scan_handler.py | Clears artwork URL/path fields during COMPLETE rescans so stale values don’t persist when no provider supplies them. |
| backend/endpoints/sockets/scan.py | Deletes existing on-disk artwork/media resources before COMPLETE rescans to prevent reuse of stale files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
Problem
A COMPLETE rescan never deleted previously downloaded asset files, and the post-scan download steps short-circuit when work appears already done:
store_media_filealways skips when the destination file exists (no overwrite param)get_cover/get_manual/get_rom_screenshotsonly re-download when the source URL changedSo covers, screenshots, manuals, and SS/gamelist/LaunchBox extended media (miximage, bezel, box3d, logo, fanart, video, …) were reused even when a fresh fetch returned a different URL. This defeated the region-priority fix in #3396: the correct region couldn't replace an already-downloaded wrong-region cover/media because the old file was still on disk and
path_cover_sstill pointed at it.Separately, when the sole provider of an artwork field was deselected, the on-disk file lingered and the
url_*DB columns kept stale values (they're never seeded for COMPLETE, and the priority loops only set fields, never clear them).Fix
endpoints/sockets/scan.py— for a COMPLETE rescan of an existing ROM, remove the cover, manual, screenshots, and every extended-media directory before re-fetching, soget_cover/store_media_filepull fresh files.handler/scan_handler.py— reseturl_cover/url_screenshots/url_manualand the matchingpath_*fields for COMPLETE rescans before the priority loops run. Stale DB values are now explicitly nulled when no selected source supplies them, rather than relying onsession.mergesemantics. Clearing for deselected sources falls out as a subset of this behavior.Testing
DB_HOST=127.0.0.1 uv run pytest tests/endpoints/sockets/test_scan.py tests/handler/filesystem/test_resources_handler.py tests/handler/test_fastapi.py— 102 passed.🤖 Generated with Claude Code