mirror of
https://github.com/Abdess/retrobios.git
synced 2026-06-27 05:02:48 +00:00
fix: move zip_contents resolution after name-based lookup
This commit is contained in:
parent
08f68e792d
commit
76064605c0
1 changed files with 13 additions and 11 deletions
|
|
@ -166,17 +166,7 @@ def resolve_local_file(
|
|||
if os.path.exists(path):
|
||||
return path, "md5_exact"
|
||||
|
||||
# 3. zipped_file content match via pre-built index
|
||||
if zipped_file and md5_list and zip_contents:
|
||||
for md5_candidate in md5_list:
|
||||
if md5_candidate in zip_contents:
|
||||
zip_sha1 = zip_contents[md5_candidate]
|
||||
if zip_sha1 in files_db:
|
||||
path = files_db[zip_sha1]["path"]
|
||||
if os.path.exists(path):
|
||||
return path, "zip_exact"
|
||||
|
||||
# 4. No MD5 = any file with that name (existence check)
|
||||
# 3. No MD5 = any file with that name (existence check)
|
||||
if not md5_list:
|
||||
candidates = []
|
||||
for match_sha1 in by_name.get(name, []):
|
||||
|
|
@ -218,6 +208,18 @@ def resolve_local_file(
|
|||
primary = [p for p, _ in candidates if "/.variants/" not in p]
|
||||
return (primary[0] if primary else candidates[0][0]), "hash_mismatch"
|
||||
|
||||
# 6. zipped_file content match via pre-built index (last resort:
|
||||
# matches inner ROM MD5 across ALL ZIPs in the repo, so only use
|
||||
# when name-based resolution failed entirely)
|
||||
if zipped_file and md5_list and zip_contents:
|
||||
for md5_candidate in md5_list:
|
||||
if md5_candidate in zip_contents:
|
||||
zip_sha1 = zip_contents[md5_candidate]
|
||||
if zip_sha1 in files_db:
|
||||
path = files_db[zip_sha1]["path"]
|
||||
if os.path.exists(path):
|
||||
return path, "zip_exact"
|
||||
|
||||
return None, "not_found"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue