Skip to content

Commit

Permalink
Delete tmpfile after use
Browse files Browse the repository at this point in the history
  • Loading branch information
emkll committed Jul 8, 2019
1 parent e94998c commit 66015d1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sd-export/send-to-usb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def exit_gracefully(msg, e=False):
sys.stderr.write("\n")
if e:
try:
# If the file archive was extracted, delete before returning
if os.path.isdir(SUBMISSION_TMPDIR):
shutil.rmtree(SUBMISSION_TMPDIR)
e_output = e.output
except Exception:
e_output = "<unknown exception>"
Expand Down Expand Up @@ -342,6 +345,9 @@ if __name__ == "__main__":
SUBMISSION_TMPDIR = tempfile.mkdtemp()

main()

# Delete extracted achive from tempfile
shutil.rmtree(SUBMISSION_TMPDIR)
except Exception as e:
# exit with 0 return code otherwise the os will attempt to open
# the file with another application
Expand Down

0 comments on commit 66015d1

Please sign in to comment.