diff --git a/scripts/scraper/fbneo_hash_scraper.py b/scripts/scraper/fbneo_hash_scraper.py index 2d5b4ad4..4b6099ef 100644 --- a/scripts/scraper/fbneo_hash_scraper.py +++ b/scripts/scraper/fbneo_hash_scraper.py @@ -29,7 +29,8 @@ log = logging.getLogger(__name__) REPO_URL = "https://github.com/finalburnneo/FBNeo.git" REPO_ROOT = Path(__file__).resolve().parent.parent.parent -CLONE_DIR = REPO_ROOT / "tmp" / "fbneo" +# One clone per process, for the reason mame_hash_scraper gives. +CLONE_DIR = REPO_ROOT / "tmp" / f"fbneo-{os.getpid()}" CACHE_PATH = REPO_ROOT / "data" / "fbneo-hashes.json" EMULATORS_DIR = REPO_ROOT / "emulators" STALE_HOURS = 24 diff --git a/scripts/scraper/mame_hash_scraper.py b/scripts/scraper/mame_hash_scraper.py index 8bdcb190..f530f302 100644 --- a/scripts/scraper/mame_hash_scraper.py +++ b/scripts/scraper/mame_hash_scraper.py @@ -31,7 +31,9 @@ log = logging.getLogger(__name__) _ROOT = Path(__file__).resolve().parents[2] _CACHE_PATH = _ROOT / "data" / "mame-hashes.json" -_CLONE_DIR = _ROOT / "tmp" / "mame" +# One clone per process: a fixed tmp/mame was removed and recloned at another +# release by a second run while the first was still parsing it. +_CLONE_DIR = _ROOT / "tmp" / f"mame-{os.getpid()}" _EMULATORS_DIR = _ROOT / "emulators" _REPO_URL = "https://github.com/mamedev/mame.git" _STALE_HOURS = 24 diff --git a/tests/test_hash_merge.py b/tests/test_hash_merge.py index c3807759..d4dbd69c 100644 --- a/tests/test_hash_merge.py +++ b/tests/test_hash_merge.py @@ -759,5 +759,20 @@ class WritersPutTheValuesOnDisk(unittest.TestCase): self.assertEqual(member["crc32"], "9036d879") +class OneCloneDirectoryPerRun(unittest.TestCase): + """Two runs shared tmp/mame: the second removed and recloned it at + another release while the first parsed it, and the first wrote 0.289 + sets into a 0.278 profile.""" + + def test_the_clone_directory_names_the_process(self): + import os + + from scripts.scraper import fbneo_hash_scraper, mame_hash_scraper + + for clone in (mame_hash_scraper._CLONE_DIR, fbneo_hash_scraper.CLONE_DIR): + with self.subTest(clone=clone.name): + self.assertTrue(clone.name.endswith(f"-{os.getpid()}")) + + if __name__ == "__main__": unittest.main()