Skip to content

Commit

Permalink
fix: Auto-delete-input-file deleting input even in error case
Browse files Browse the repository at this point in the history
  • Loading branch information
georgkoester committed Dec 18, 2024
1 parent 6ac52de commit 2a8995c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions redact/v4/tools/redact_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,22 @@ def redact_file(
finally:
if licence_plate_custom_stamp:
licence_plate_custom_stamp.close()

# End of finally. Delete input file etc should not be included in finally.

# delete input file
if auto_delete_input_file:
log.debug(f"Deleting {file_path}")
Path(file_path).unlink()

try:
# delete job
if auto_delete_job:
log.debug(f"Deleting job {job.output_id}")
job.delete()
except UnboundLocalError:
# if the starting the job failed, there is no job variable and this Exception will be thrown
pass
# delete input file
if auto_delete_input_file:
log.debug(f"Deleting {file_path}")
Path(file_path).unlink()

try:
# delete job
if auto_delete_job:
log.debug(f"Deleting job {job.output_id}")
job.delete()
except UnboundLocalError:
# if the starting the job failed, there is no job variable and this Exception will be thrown
pass

return job_status

Expand Down

0 comments on commit 2a8995c

Please sign in to comment.