fix: settle export sizes, never write None

A truth that accepts several sizes left an export with no size even
where the platform states one of them for the same dump, and RomM's
fixture then received the string None, which RomM cannot parse. A
size list now admits the platform's own size, RomM keeps its value
when nothing settles one, and validation requires a number.
This commit is contained in:
Abdessamad Derraz committed 2026-10-18 04:07:57 +02:00
1 parent c6c216ecb5
commit 9c0a430f5c
3 files changed
+85 -7

No files matched your search

+14 -2
View File
@@ -188,9 +188,21 @@ class NativeFile:
"platform": (self.platform, self.truth),
"truth": (self.truth,),
}.get(source, (self.truth, self.platform))
# A list names every size the code accepts (geargrafx's syscard3.pce,
# headerless or headered). It states no single size, but it still
# admits the one the platform writes: System.dat's 262144 for the
# same md5 lost its size field when the list came first.
accepted: set[int] | None = None
for entry in order:
if entry and entry.get("size"):
return _single_size(entry["size"])
if not entry or not entry.get("size"):
continue
single = _single_size(entry["size"])
if single is None:
if accepted is None:
accepted = {int(v) for v in entry["size"]}
continue
if accepted is None or single in accepted:
return single
return None
def native(self, key: str, default: object = "") -> object:
+8 -2
View File
@@ -127,7 +127,13 @@ class Exporter(BaseExporter):
continue
entry: OrderedDict[str, str] = OrderedDict()
# The fixture states every value as a string, size included.
entry["size"] = str(fe.size())
# Where the model settles no size, RomM's own value stands;
# str(None) wrote "None", and RomM's int() on it raised.
size = fe.size()
if size is None and fe.platform is not None:
size = fe.platform.get("size")
if size is not None:
entry["size"] = str(int(size))
crc = fe.record_hash("crc32")
if crc:
entry["crc"] = crc
@@ -159,7 +165,7 @@ class Exporter(BaseExporter):
issues.append(f"key without a platform slug: {key}")
elif not self._known_platform(slug):
issues.append(f"platform slug RomM does not know: {slug}")
if not entry.get("size"):
if not str(entry.get("size", "")).isdigit():
issues.append(f"entry without a size, never verifiable: {key}")
if not any(entry.get(h) for h in ("md5", "sha1", "crc")):
issues.append(f"entry without a hash, never verifiable: {key}")