diff --git a/tools/awc_shorts.py b/tools/awc_shorts.py index 89b31c460..82f3b4a73 100644 --- a/tools/awc_shorts.py +++ b/tools/awc_shorts.py @@ -161,10 +161,15 @@ def main(argv=None) -> int: print(f"awc_shorts: cannot list {e.filename or a.src}: {e.strerror or e}", file=sys.stderr) return 2 catalog = os.path.join(a.out, "shorts.csv") - for path, _ in banks: + # Both refusals run before the output folder is created, so a refused run leaves nothing behind. + for path, bank in banks: if same_report_path(catalog, path): print(f"awc_shorts: error: catalog would overwrite the input bank {path}", file=sys.stderr) return 2 + target = os.path.join(a.out, bank) + if same_report_path(catalog, target): + print(f"awc_shorts: error: catalog would collide with bank export directory {target}", file=sys.stderr) + return 2 try: os.makedirs(a.out, exist_ok=True) except OSError as e: @@ -173,9 +178,6 @@ def main(argv=None) -> int: destinations = {} for path, bank in banks: target = os.path.join(a.out, bank) - if same_report_path(catalog, target): - print(f"awc_shorts: error: catalog would collide with bank export directory {target}", file=sys.stderr) - return 2 key = path_key(target) if key in destinations: print(f"awc_shorts: error: {destinations[key]} and {path} would both export to {target}", file=sys.stderr)