Update iso-prototype.py

This commit is contained in:
Kroese
2026-07-28 16:27:24 +02:00
committed by GitHub
parent 441a044196
commit 6025512225
+22 -4
View File
@@ -361,13 +361,30 @@ def iso_candidates(path: PurePosixPath, is_dir: bool = False) -> list[str]:
return [base + ";1", base]
def find_existing_record(iso, logical: PurePosixPath) -> dict[str, str]:
def find_existing_record(
iso,
logical: PurePosixPath,
*,
is_dir: bool = False,
) -> dict[str, str]:
found: dict[str, str] = {}
iso_paths = iso_candidates(logical, is_dir=is_dir)
alias_path = iso9660_alias_path(
iso,
logical,
is_dir=is_dir,
)
if alias_path not in iso_paths:
iso_paths.append(alias_path)
probes = {
"udf_path": [str(logical)],
"joliet_path": [str(logical)],
"iso_path": iso_candidates(logical),
"iso_path": iso_paths,
}
for namespace, candidates in probes.items():
for candidate in candidates:
try:
@@ -376,6 +393,7 @@ def find_existing_record(iso, logical: PurePosixPath) -> dict[str, str]:
continue
found[namespace] = candidate
break
return found
@@ -494,7 +512,7 @@ def ensure_parent_directories(iso, logical: PurePosixPath) -> None:
if part == "/":
continue
current /= part
if find_existing_record(iso, current):
if find_existing_record(iso, current, is_dir=True):
continue
iso.add_directory(**namespace_kwargs(iso, current, is_dir=True))
@@ -569,7 +587,7 @@ def sync_tree(iso, tree: Path, logical_root: PurePosixPath) -> None:
rel = root_path.relative_to(tree)
logical_dir = PurePosixPath("/") / PurePosixPath(rel.as_posix())
ensure_parent_directories(iso, logical_dir / "placeholder")
if not find_existing_record(iso, logical_dir):
if not find_existing_record(iso, logical_dir, is_dir=True):
iso.add_directory(**namespace_kwargs(iso, logical_dir, is_dir=True))
for name in files:
logical = logical_dir / name