fix: resolve large files from cache in database paths

This commit is contained in:
Abdessamad Derraz
2026-03-25 12:52:20 +01:00
parent 21465effff
commit 910428c6f1
2 changed files with 14 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
{
"generated_at": "2026-03-25T11:16:01Z",
"generated_at": "2026-03-25T11:51:38Z",
"total_files": 6733,
"total_size": 5288644732,
"files": {
@@ -67294,7 +67294,7 @@
"adler32": "dbd42440"
},
"b48f44194fe918aaaec5298861479512b581d661": {
"path": "bios/Nintendo/Nintendo DS/dsi_nand.bin",
"path": ".cache/large/dsi_nand.bin",
"name": "dsi_nand.bin",
"size": 251658304,
"sha1": "b48f44194fe918aaaec5298861479512b581d661",
@@ -67304,7 +67304,7 @@
"adler32": "3b3e7d56"
},
"093f8698b54b78dcb701de2043f82639de51d63b": {
"path": "bios/Sony/PlayStation 3/PS3UPDAT.PUP",
"path": ".cache/large/PS3UPDAT.PUP",
"name": "PS3UPDAT.PUP",
"size": 206126236,
"sha1": "093f8698b54b78dcb701de2043f82639de51d63b",
@@ -67314,7 +67314,7 @@
"adler32": "1ec0b1c3"
},
"ed3a4cb264fff283209f10ae58c96c6090fed187": {
"path": "bios/Sony/PlayStation Vita/PSP2UPDAT.PUP",
"path": ".cache/large/PSP2UPDAT.PUP",
"name": "PSP2UPDAT.PUP",
"size": 56778752,
"sha1": "ed3a4cb264fff283209f10ae58c96c6090fed187",
@@ -67324,7 +67324,7 @@
"adler32": "620a2ff1"
},
"cc72dfcc964577cc29112ef368c28f55277c237c": {
"path": "bios/Sony/PlayStation Vita/PSVUPDAT.PUP",
"path": ".cache/large/PSVUPDAT.PUP",
"name": "PSVUPDAT.PUP",
"size": 133834240,
"sha1": "cc72dfcc964577cc29112ef368c28f55277c237c",

View File

@@ -236,6 +236,9 @@ def _preserve_large_file_entries(files: dict, db_path: str) -> int:
in .gitignore. When generate_db runs locally without them, their
entries would be lost. This reads the existing database and re-adds
entries whose paths match .gitignore bios/ entries.
If the file exists in .cache/large/, the path is updated so that
resolve_local_file can find it for verify and pack generation.
"""
gitignored = _load_gitignored_bios_paths()
if not gitignored:
@@ -247,10 +250,16 @@ def _preserve_large_file_entries(files: dict, db_path: str) -> int:
except (FileNotFoundError, json.JSONDecodeError):
return 0
cache_dir = Path(".cache/large")
count = 0
for sha1, entry in existing_db.get("files", {}).items():
path = entry.get("path", "")
if path in gitignored and sha1 not in files:
# Point to cached copy if available
name = entry.get("name", "")
cached = cache_dir / name
if cached.exists():
entry = {**entry, "path": str(cached)}
files[sha1] = entry
count += 1
return count