From fe25a7caa0304fadece60f304f54609045e24098 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 17 Nov 2026 07:56:09 +0100 Subject: [PATCH] refactor: tidy packpaths and torrentzip returns --- scripts/packpaths.py | 4 +--- scripts/torrentzip.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/scripts/packpaths.py b/scripts/packpaths.py index c7b953432..045417a45 100644 --- a/scripts/packpaths.py +++ b/scripts/packpaths.py @@ -161,9 +161,7 @@ def _has_path_conflict(dest: str, seen_files: set[str], seen_parents: set[str]) for parent in _path_parents(dest): if parent in seen_files: return True - if dest in seen_parents: - return True - return False + return dest in seen_parents def placement_block( dest: str, diff --git a/scripts/torrentzip.py b/scripts/torrentzip.py index 5e2faff66..41f1588fb 100644 --- a/scripts/torrentzip.py +++ b/scripts/torrentzip.py @@ -217,6 +217,8 @@ def main() -> int: parser.add_argument("--rebuild", metavar="ZIP", help="normalize an archive") parser.add_argument("--output", "-o", help="output path for --rebuild") args = parser.parse_args() + if not (args.check or args.rebuild): + parser.error("nothing to do: pass --check or --rebuild") if args.check: data = Path(args.check).read_bytes() @@ -228,14 +230,11 @@ def main() -> int: print(f" conform: {data == rebuilt}") return 0 if data == rebuilt else 1 - if args.rebuild: - data = rebuild_torrentzip(args.rebuild) - dest = args.output or args.rebuild - Path(dest).write_bytes(data) - print(f"{dest}: {len(data)} bytes, md5 {hashlib.md5(data).hexdigest()}") - return 0 - - parser.error("nothing to do: pass --check or --rebuild") + data = rebuild_torrentzip(args.rebuild) + dest = args.output or args.rebuild + Path(dest).write_bytes(data) + print(f"{dest}: {len(data)} bytes, md5 {hashlib.md5(data).hexdigest()}") + return 0 if __name__ == "__main__":