mirror of
https://github.com/rommapp/romm.git
synced 2026-12-02 10:08:40 +01:00
fix(scan): hash game folders in sorted file order (#5421)
This commit is contained in:
@@ -665,6 +665,8 @@ class FSRomsHandler(FSHandler):
|
||||
entries.append((f_path, file_name, os.stat(Path(f_path, file_name))))
|
||||
except OSError as exc:
|
||||
log.warning(f"Skipping unreadable file {f_path / file_name}: {exc}")
|
||||
# Listing order is filesystem-specific; the ROM-level hash must not be.
|
||||
entries.sort(key=lambda e: Path(e[0], e[1]).as_posix())
|
||||
return entries
|
||||
|
||||
async def converto_active(self, platform_slug: str) -> bool:
|
||||
|
||||
@@ -1387,6 +1387,26 @@ class TestFSRomsHandler:
|
||||
if test_file.exists():
|
||||
test_file.unlink()
|
||||
|
||||
def test_list_rom_dir_sorts_regardless_of_listing_order(
|
||||
self, handler: FSRomsHandler, config, tmp_path
|
||||
):
|
||||
rom_dir = tmp_path / "Order Test (World)"
|
||||
(rom_dir / "sub").mkdir(parents=True)
|
||||
for name in ("a.bin", "b.bin", "sub/c.bin"):
|
||||
(rom_dir / name).write_bytes(b"x")
|
||||
listing = [(rom_dir, "b.bin"), (rom_dir / "sub", "c.bin"), (rom_dir, "a.bin")]
|
||||
|
||||
with patch(
|
||||
"handler.filesystem.roms_handler.iter_files", return_value=iter(listing)
|
||||
):
|
||||
entries = handler._list_rom_dir(rom_dir, config)
|
||||
|
||||
assert [(p, n) for p, n, _ in entries] == [
|
||||
(rom_dir, "a.bin"),
|
||||
(rom_dir, "b.bin"),
|
||||
(rom_dir / "sub", "c.bin"),
|
||||
]
|
||||
|
||||
def test_failed_7z_extraction_hashes_only_the_raw_archive(
|
||||
self, handler: FSRomsHandler, tmp_path
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user