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 273528c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sd-export/send-to-usb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import json
import os
import shutil
import signal
import subprocess
import sys
Expand All @@ -22,6 +23,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 +346,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 273528c

Please sign in to comment.