refactor: importers write through write_if_changed

game_dat_importer and arcade_parent_importer each kept an exact-text
copy of write_if_changed, so a redump refresh rewrote every catalog for
its fetched date alone. Both now use artifacts.write_if_changed, which
treats fetched as a timestamp. A No-Intro rebuild still rewrites its
catalogs, since asset_updated_at moves with it, so check_freshness keeps
reading a fetched date no older than the pack.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 08:13:32 +01:00
1 parent 5c93c6dc6b
commit 57ccca640a
4 files changed
+19 -20

No files matched your search

+11
View File
@@ -102,6 +102,17 @@ class FixtureImport(unittest.TestCase):
twin = second / path.relative_to(first)
self.assertEqual(path.read_bytes(), twin.read_bytes(), path.name)
def test_a_new_fetch_date_alone_rewrites_nothing(self) -> None:
"""A refresh rewrote every catalog for the day it ran, and the diff
read before commit no longer showed which DAT had moved."""
self.assertEqual(run_import("redump", self.out).returncode, 0)
path = self.out / "redump" / "sega-megacd.json"
doc = json.loads(path.read_text())
doc["fetched"] = "2000-01-01"
path.write_text(importer.dump_catalog(doc))
self.assertEqual(run_import("redump", self.out).returncode, 0)
self.assertEqual(json.loads(path.read_text())["fetched"], "2000-01-01")
def test_floor_refuses_a_short_dat(self) -> None:
result = run_import("no-intro", self.out, "--floor", "--dry-run")
self.assertEqual(result.returncode, 1)