fix: read a database record by its path field

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:01:46 +01:00
1 parent db9a153832
commit 2308039452
5 files changed
+16 -33

No files matched your search

+4 -11
View File
@@ -294,24 +294,17 @@ def lookup_hashes(
entry = files_db[sha1]
name = entry.get("name", "?")
md5 = entry.get("md5", "?")
paths = entry.get("paths") or []
aliases = entry.get("aliases") or []
path = entry.get("path", "")
print(f"\n{hash_type.upper()}: {hash_val}")
print(f" SHA1: {sha1}")
print(f" MD5: {md5}")
print(f" Name: {name}")
if paths:
print(f" Path: {paths[0]}")
if aliases:
print(f" Aliases: {aliases}")
if path:
print(f" Path: {path}")
# Check if file exists in repo (by path or by resolve_local_file)
in_repo = False
if paths:
primary = os.path.join(bios_dir, paths[0])
if os.path.exists(primary):
in_repo = True
in_repo = bool(path) and os.path.exists(path)
if not in_repo:
try:
fe_check = {"name": name, "sha1": sha1, "md5": md5}
+3 -7
View File
@@ -458,11 +458,8 @@ def _check_duplicate(result: ValidationResult, db: dict, relative: str) -> None:
result.add_check(True, "Not a duplicate in database")
return
existing = db["files"][result.sha1]
held_at = {
os.path.normpath(p)
for p in [existing.get("path"), *(existing.get("paths") or [])] if p
}
if os.path.normpath(relative) in held_at:
held_at = existing.get("path")
if held_at and os.path.normpath(relative) == os.path.normpath(held_at):
# The file the database was built from, not a copy of it: a
# PR that regenerated database.json was told each new file
# duplicated itself.
@@ -859,8 +856,7 @@ def _held_directories(db: dict | None) -> frozenset[str]:
_HELD_DIRECTORIES[key] = frozenset(
path.rsplit("/", 1)[0] + "/"
for record in (db or {}).get("files", {}).values()
for path in [record.get("path"), *(record.get("paths") or [])]
if path and "/" in path and "/.variants/" not in path
if "/" in (path := record.get("path") or "") and "/.variants/" not in path
)
return _HELD_DIRECTORIES[key]