mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
fix: identity scan walks only collection files
This commit is contained in:
1 parent
2ee77a0622
commit
a96a0a4641
2 files changed
+13
-4
No files matched your search
@@ -18,8 +18,9 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from core.paths import BIOS_DIR
|
||||
from core.collectionfiles import collection_files
|
||||
from core.hashing import file_digest
|
||||
from core.paths import BIOS_DIR
|
||||
from resolve.ownership import maker_of_relative
|
||||
|
||||
|
||||
@@ -69,12 +70,12 @@ def scan(bios_dir: str = BIOS_DIR) -> list[Duplicate]:
|
||||
|
||||
Only files that share a size can share a content, so a size held by one
|
||||
file is never read: hashing the whole tree read 18 GB on every pipeline.
|
||||
The walk is the database scan's: a copy under `.cache/` is no identity.
|
||||
"""
|
||||
by_size: dict[int, list[Path]] = {}
|
||||
root = Path(bios_dir)
|
||||
for path in sorted(root.rglob("*")):
|
||||
if path.is_file():
|
||||
by_size.setdefault(path.stat().st_size, []).append(path)
|
||||
for path in collection_files(root):
|
||||
by_size.setdefault(path.stat().st_size, []).append(path)
|
||||
by_content: dict[str, list[Path]] = {}
|
||||
for paths in by_size.values():
|
||||
if len(paths) < 2:
|
||||
|
||||
@@ -53,6 +53,14 @@ class TestCrossVendorDuplicates(unittest.TestCase):
|
||||
self._write("Sinclair/ZX Spectrum/48.rom", b"rom")
|
||||
self.assertEqual(self._scan(), [])
|
||||
|
||||
def test_a_copy_outside_the_collection_is_no_identity(self):
|
||||
# The database scan leaves .cache/ and hidden files out: a stray
|
||||
# copy there is not a second name for the dump.
|
||||
self._write("Commodore/Amiga/kickstart.rom", b"kick")
|
||||
self._write(".cache/Sega/cartridge.bin", b"kick")
|
||||
self._write("Sega/Saturn/.cartridge.bin", b"kick")
|
||||
self.assertEqual(self._scan(), [])
|
||||
|
||||
def test_an_explained_crossing_is_silent(self):
|
||||
self._write("Magnavox/Odyssey2/o2rom.bin", b"odyssey")
|
||||
self._write("Philips/Videopac/O2.bin", b"odyssey")
|
||||
|
||||
Reference in new issue
Block a user