Restructured how temporary paths are calculated

This commit is contained in:
Joel Collins 2019-04-09 14:52:08 +01:00
parent 24ded8de32
commit 61f15d610f

View file

@ -215,6 +215,12 @@ class CaptureObject(object):
"""
global TEMP_CAPTURE_PATH
if self.temporary:
# Store original file path
self.file_notmp = os.path.join(folder, filename)
# Move user-specified folder to TEMP
self.folder = os.path.join(TEMP_CAPTURE_PATH, self.folder)
self.file = os.path.join(folder, filename) # Full file name by joining given folder to given name
self.split_file_path(self.file) # Split file path into folder, filename, and basename
@ -223,12 +229,6 @@ class CaptureObject(object):
if not os.path.commonprefix([self.file, BASE_CAPTURE_PATH]) == BASE_CAPTURE_PATH:
raise Exception("Captures cannot be stored in a lower-level directory than {}.".format(BASE_CAPTURE_PATH))
# Move to tmp directory if not being kept
if self.temporary:
self.file_notmp = self.file # Store originally defined folder
self.filefolder = TEMP_CAPTURE_PATH
self.file = os.path.join(self.filefolder, self.filename)
# Create folder and file
if not os.path.exists(self.filefolder):
os.makedirs(self.filefolder)