mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 09:08:38 +00:00
awc_shorts: refuse a catalog collision before creating the output folder
Review follow-up from #934: the bank export directory check ran after os.makedirs, so a refused run left an empty output folder. Both collision checks now run first, and a test checks that out/ is not created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user