Commit Graph

3664 Commits

Author SHA1 Message Date
Georges-Antoine Assi
207d0dc4c6 feat(hashing): persist per-member hashes on archive RomFile
Internal members of multi-file archives (zip/tar/7z/rar) are now hashed
individually (crc/md5/sha1) and stored in a new `archive_members` JSON
column on the archive's RomFile, alongside the existing composite hash
used for hash-database matching. Only the archive itself is surfaced as
a RomFile so full_path keeps pointing at a file that exists on disk,
which is the constraint that previously forced us to choose between
composite-only or broken downloads.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 09:41:04 -04:00
Georges-Antoine Assi
9111f70d0a refactor(filesystem): merge archive_7zip.py into archives.py
Consolidate all archive readers (zip/tar/7z/rar) and 7z-internal helpers
into a single utils/archives.py module to keep the archive surface area
in one place.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 09:10:01 -04:00
Georges-Antoine Assi
a1194dc5e0 changes from bot review 2026-05-28 09:02:26 -04:00
Georges-Antoine Assi
a170649fe6 fix(hashing): emit single RomFile for multi-file archives
Per-internal-member RomFiles produced full_paths that didn't exist on
disk, breaking downloads and zip-building. Stream entries into the
composite hash only and emit one RomFile pointing at the archive itself.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 21:35:01 -04:00
Georges-Antoine Assi
0bfe369425 run fmt 2026-05-27 21:03:08 -04:00
Georges-Antoine Assi
acff688f11 refactor(hashing): use _make_file_hash helper at remaining sites
Apply the helper to the three other per-file FileHash constructions
(folder-walk hash, empty-archive fallback, single-file hash). The
all-empty FileHash literals are left alone since the helper would be
strictly more obscure for that case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 09:12:11 -04:00
Georges-Antoine Assi
f255b5a7d9 feat(hashing): add RAR support to multi-file archive composite hashing
Add read_rar_archive_files via the existing 7zz binary (which natively
handles RAR3/RAR5 read), and collapse the per-extension reader dispatch
into an ARCHIVE_READERS dict so future formats are one entry away. Also
extract a small _make_file_hash helper to remove the repeated nested
ternaries in the inner loop.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 09:09:37 -04:00
Georges-Antoine Assi
438c03facc refactor(filesystem): extract archive/CHD helpers to utils/archives.py
Pull file/archive readers (zip/tar/gz/bz2/7z), CHD parsing, and the
shared libmagic MIME detector out of roms_handler.py into a new
utils/archives.py. Rename the previously underscore-prefixed
read_zip_archive_files / read_tar_archive_files to match the existing
read_7z_archive_files convention, and consolidate the duplicated
"with lock: detector.from_file()" pattern into a detect_mime_type helper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 08:41:45 -04:00
Spinnich
242dc9e357 fix(hashing): use only default exclusions for archive internal files
User-configured EXCLUDED_MULTI_PARTS_EXT/FILES are intentionally not
applied to archive internal files. Archives are curated ROM sets where
every file is relevant — user custom exclusions (e.g. "bin") could
silently produce incorrect composite hashes. Only the hardcoded
DEFAULT_EXCLUDED_FILES/EXTENSIONS (junk like .DS_Store, gamelist.xml)
are applied.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 12:28:49 +00:00
Spinnich
a9f9ea2edc fix(hashing): address trunk lint issues in composite archive hashing
- Use AnyioPath.stat() instead of os.path.getmtime in async context (ASYNC240)
- Add assert to narrow rom_md5_h/rom_sha1_h from HASH|None to HASH (mypy/union-attr)
- Auto-formatted long log.error calls in archive_7zip.py (ruff)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 12:14:39 +00:00
Spinnich
c20d48bbf8 feat(hashing): compute both composite hash & individual files hash for multi-file archives
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 12:04:04 +00:00
Georges-Antoine Assi
d7c789c4c4 Merge pull request #3400 from rommapp/copilot/fix-steamgriddb-igdb-matching
Fix IGDB/SGDB matching wrong game for standalone expansions (e.g. Ecco: The Tides of Time)
2026-05-21 18:38:58 -04:00
Georges-Antoine Assi
1377e2991d fix test again 2026-05-21 18:30:30 -04:00
Georges-Antoine Assi
745d8b959c fix test 2026-05-21 18:25:46 -04:00
Georges-Antoine Assi
f9c0a8f966 run fmt 2026-05-21 18:09:01 -04:00
Georges-Antoine Assi
7885f5eeb9 Merge pull request #3401 from rommapp/copilot/fix-metadata-id-fetch-issue
Fix: UNMATCHED scan ignores manually-set metadata IDs when metadata is absent
2026-05-21 18:08:40 -04:00
Georges-Antoine Assi
f4512cb968 run fmt 2026-05-21 17:59:44 -04:00
Georges-Antoine Assi
d1958f2aae run fmt 2026-05-21 17:19:12 -04:00
Georges-Antoine Assi
1be2ca2b3c soimplify 2026-05-21 17:17:30 -04:00
Georges-Antoine Assi
600adb2c33 drop unused tests 2026-05-21 17:14:32 -04:00
Georges-Antoine Assi
f40aa806ad manual cleanup 2026-05-21 17:12:05 -04:00
copilot-swe-agent[bot]
98bc9a9eea Optimize multi-ROM exclusion matching pass
Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-21 18:52:55 +00:00
copilot-swe-agent[bot]
5a1e238a5f perf: pre-normalize exclusions once and use set for O(1) lookup in exclude_multi_roms
Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-21 18:50:45 +00:00
copilot-swe-agent[bot]
90bbf6c9d1 fix: fetch metadata for manually-set IDs on UNMATCHED scan
When a user manually sets metadata IDs (e.g., ra_id, launchbox_id, hasheous_id)
via the UI and then runs "Refresh Metadata" (which defaults to UNMATCHED scan type),
no metadata was fetched because UNMATCHED conditions checked `not rom.xxx_id` — so
if the ID was already set, the handler was skipped entirely.

Fix: Change each handler's UNMATCHED condition to also trigger when the ID is set
but the corresponding metadata dict is empty (i.e., `not rom.xxx_id or not rom.xxx_metadata`).
For handlers that support ID-based lookup (RA, Launchbox, IGDB, MobyGames, SS,
Flashpoint), also add the `get_rom_by_id` path inside the function.

For Hasheous: when hash lookup fails but `hasheous_id` is set on an existing ROM
(not newly added), return a partial HasheousRom built from the existing sub-IDs
(igdb_id, ra_id, tgdb_id) so the downstream get_igdb_game / get_ra_game proxy
calls can still enrich the ROM.

Add three targeted tests to validate:
- UNMATCHED scan fetches RA metadata when ra_id is set but ra_metadata is empty
- UNMATCHED scan skips RA when both ra_id and ra_metadata are already populated
- UNMATCHED scan passes existing sub-IDs to Hasheous proxies when hash lookup fails

Agent-Logs-Url: https://github.com/rommapp/romm/sessions/098b482f-9f73-4f35-819a-b55004a79b13

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-21 11:41:23 +00:00
copilot-swe-agent[bot]
3ea960d008 fix: IGDB/SGDB scraping incorrectly matches standalone expansions to parent game
- Add `STANDALONE_EXPANSION` game type to the `with_game_type` filter in
  `_search_rom` so games like "Ecco: The Tides of Time" (which IGDB classifies
  as a standalone expansion) are included in the first search pass and are not
  confused with their parent game ("Ecco The Dolphin")
- Fix the expanded search fallback to fetch and compare ALL unique game IDs
  returned by the IGDB search endpoint, instead of only the first result
- Add tests to verify both fixes

Agent-Logs-Url: https://github.com/rommapp/romm/sessions/d6a0c1dd-e541-4d8e-a272-9e5511a2077e

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-21 11:30:23 +00:00
copilot-swe-agent[bot]
9e3f85b085 Fix ES-DE multi-folder exclusion matching
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/2213cb94-9971-48a6-8d17-9efc5c209db4

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-21 11:22:21 +00:00
Georges-Antoine Assi
94d011ee5e tolerate launchbox basepath 2026-05-21 06:56:36 -04:00
Georges-Antoine Assi
ce20d403aa Merge pull request #3396 from rommapp/fix-ss-multi-region-priority
fix(screenscraper): respect region priority for multi-region ROMs
2026-05-20 20:21:50 -04:00
Georges-Antoine Assi
4f5f85554f Merge pull request #3395 from rommapp/copilot/fix-complete-rescan-metadata
Fix Complete Rescan not clearing unselected metadata sources
2026-05-20 18:51:45 -04:00
Georges-Antoine Assi
a245ac7330 fix lint 2026-05-20 18:13:09 -04:00
Georges-Antoine Assi
aeb17b95a8 add tests 2026-05-20 18:10:25 -04:00
Georges-Antoine Assi
2e7beeec5b remove meta source fields 2026-05-20 17:43:50 -04:00
Georges-Antoine Assi
6c84241ef5 Extract METADATA_SOURCE_FIELDS constant in scan_handler
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 17:37:20 -04:00
Georges-Antoine Assi
fe5af3ef9c fix(screenscraper): respect region priority for multi-region ROMs
For ROMs tagged with multiple regions (e.g. "(Japan, USA)"), filename order
previously decided which region's name and box art won. Now reorder the rom's
filename-tagged regions by SCAN_REGION_PRIORITY before prepending, so the
user's configured preference wins among the regions the file is actually
tagged as. Untagged priority regions still cannot outrank a filename-tagged
region.

Also tweak the Total Rescan → Complete Rescan label in en_GB/en_US scan
locales.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 17:20:54 -04:00
copilot-swe-agent[bot]
440f55ba89 Fix Complete Rescan not clearing unselected metadata sources
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/e76abf0d-7039-4dae-ad88-5f1f1c4f422f

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-20 19:15:56 +00:00
copilot-swe-agent[bot]
f284ef2fba fix: treat libretro-matched roms as identified
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/9cc2e55e-af48-40bd-b2e9-492b6fd6046a

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
2026-05-20 19:14:35 +00:00
Georges-Antoine Assi
21663fc922 cleanup fomratter 2026-05-20 09:17:35 -04:00
Georges-Antoine Assi
052245f344 Merge pull request #3384 from Spinnich/pr/screenscraper-api-and-redaction
fix(screenscraper): improve API handling, KO scrape data, and metadata sanitization
2026-05-20 09:11:36 -04:00
Spinnich
12c424f829 fix(screenscraper): improve API handling and redact credentials in logs
Fix several issues in ScreenScraper API request/response handling:

- Correctly handle SS-specific HTTP error codes (KO responses, 429, 431,
  and the SS-quirk of returning 401 when server CPU >60%).
- Construct requests with proper parameter encoding so jeuInfos lookups
  and search queries return the expected results.
- Store media URLs returned by SS as-is, preserving the dev credential
  query parameters required for media playback. Removing them broke
  downstream media fetches.

To keep dev credentials out of log output, add a redacting formatter in
the logger pipeline that scrubs ssid/sspassword/devid/devpassword query
parameters from any URL it sees.

Test coverage added for the new HTTP error paths and the as-is URL
storage behaviour.
2026-05-19 19:39:55 -04:00
Georges-Antoine Assi
405f678514 Merge pull request #3388 from rommapp/hardlink-resources-gamelist
feat(fs): hardlink import/export assets, harden sync init
2026-05-19 09:04:18 -04:00
Georges-Antoine Assi
584f35b797 changes from bot review 2026-05-19 07:52:43 -04:00
Georges-Antoine Assi
adb050f164 commit and push 2026-05-19 07:31:25 -04:00
Georges-Antoine Assi
8c3d82784f fix cleanup orphaned resources 2026-05-18 20:30:18 -04:00
Georges-Antoine Assi
f84796da08 Merge pull request #3385 from Spinnich/pr/chd-raw-hashing
feat(hashing): compute raw CHD hashes and route disc-data SHA1 to Hasheous
2026-05-18 14:52:54 -04:00
Georges-Antoine Assi
591b07ec49 changes from bot review 2026-05-18 14:44:52 -04:00
Georges-Antoine Assi
e6d4ede939 cleanup 2026-05-18 07:40:59 -04:00
Georges-Antoine Assi
757fafae5f feat(fs): hardlink import/export assets when possible, harden sync init
Importer (gamelist/launchbox file:// flows) and exporters (gamelist.xml,
metadata.pegasus.txt local exports) now hardlink media assets when source
and destination share a filesystem, falling back transparently to a copy
on EXDEV / EPERM / EOPNOTSUPP / EMLINK / EACCES (cross-device, FAT32,
exFAT, network mounts, etc.). Saves disk space and is effectively
instantaneous on large files (videos, manuals, miximages).

Covers keep a real copy (allow_link=False) because _store_cover resizes
the small cover in place via PIL.Image.save, which would truncate the
shared inode and corrupt the user's source image.

Also makes FSSyncHandler tolerate a missing/unwritable /romm/sync at
startup: an OSError from mkdir now logs a warning instead of crashing
the whole app at module-import time. Sync calls still fail at use time
if the mount remains broken — the right place to surface the error.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 07:38:11 -04:00
Georges-Antoine Assi
3557850701 refactor 2026-05-17 17:52:14 -04:00
Georges-Antoine Assi
51f0522193 undo 2026-05-17 17:39:47 -04:00
Georges-Antoine Assi
46357f0fa2 test: set SYNC_BASE_PATH to romm_test/sync for pytest
CI runs pytest without root, so the new /var/lib/romm/sync default
fails when FSSyncHandler tries to mkdir its base path at import time.
The other handlers stay writable in tests because they derive from
ROMM_BASE_PATH=romm_test (relative); pin SYNC_BASE_PATH the same way.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 17:25:23 -04:00