mirror of
https://github.com/rommapp/romm.git
synced 2026-12-05 05:07:31 +01:00
Merge pull request #3406 from rommapp/wipe-resources-complete-rescan
fix: wipe downloaded resources on COMPLETE rescan
This commit is contained in:
@@ -11,6 +11,7 @@ from rq import Worker
|
||||
from rq.job import Job
|
||||
|
||||
from config import DEV_MODE, REDIS_URL, SCAN_TIMEOUT, SCAN_WORKERS, TASK_RESULT_TTL
|
||||
from config.config_manager import MetadataMediaType
|
||||
from config.config_manager import config_manager as cm
|
||||
from endpoints.responses import TaskType
|
||||
from endpoints.responses.platform import PlatformSchema
|
||||
@@ -295,6 +296,36 @@ async def _identify_rom(
|
||||
}
|
||||
)
|
||||
|
||||
# For a COMPLETE rescan, wipe all downloaded resources before re-fetching so
|
||||
# stale files (e.g. a cover from the wrong region) can't be reused. The
|
||||
# post-scan download steps below skip downloads when a file already exists or
|
||||
# when the source URL is unchanged, so the on-disk files must be removed here.
|
||||
if not newly_added and scan_type == ScanType.COMPLETE:
|
||||
try:
|
||||
await fs_resource_handler.remove_cover(rom)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
try:
|
||||
await fs_resource_handler.remove_manual(rom)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
try:
|
||||
await fs_resource_handler.remove_directory(
|
||||
f"{rom.fs_resources_path}/screenshots"
|
||||
)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
for media_type in MetadataMediaType:
|
||||
try:
|
||||
await fs_resource_handler.remove_media_resources_path(
|
||||
platform.id, rom.id, media_type
|
||||
)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
log.debug(f"Scanning {rom.fs_name}...")
|
||||
scanned_rom = await scan_rom(
|
||||
scan_type=scan_type,
|
||||
|
||||
@@ -888,6 +888,19 @@ async def scan_rom(
|
||||
if fields["metadata_field"]:
|
||||
rom_attrs[fields["metadata_field"]] = {}
|
||||
|
||||
# Reset artwork fields so stale values are cleared when no source supplies them
|
||||
rom_attrs.update(
|
||||
{
|
||||
"url_cover": "",
|
||||
"url_screenshots": [],
|
||||
"url_manual": "",
|
||||
"path_cover_s": "",
|
||||
"path_cover_l": "",
|
||||
"path_screenshots": [],
|
||||
"path_manual": "",
|
||||
}
|
||||
)
|
||||
|
||||
# Determine which metadata sources are available
|
||||
available_sources = [
|
||||
name
|
||||
|
||||
Reference in New Issue
Block a user