Commit 899f5736 by Máhonfai Bálint

Fix errors with unlinking

parent 2b4ce60c
...@@ -301,17 +301,20 @@ class Disk(object): ...@@ -301,17 +301,20 @@ class Disk(object):
self.get_path()] self.get_path()]
subprocess.check_output(cmdline) subprocess.check_output(cmdline)
except AbortException: except AbortException:
os.unlink(downloaded_file) if os.path.exists(downloaded_file):
os.unlink(downloaded_file)
if os.path.exists(self.get_path()): if os.path.exists(self.get_path()):
os.unlink(self.get_path()) os.unlink(self.get_path())
logger.info("Import of disk %s aborted" % self.name) logger.info("Import of disk %s aborted" % self.name)
except: except:
os.unlink(downloaded_file) if os.path.exists(downloaded_file):
os.unlink(downloaded_file)
if os.path.exists(self.get_path()): if os.path.exists(self.get_path()):
os.unlink(self.get_path()) os.unlink(self.get_path())
raise raise
else: else:
os.unlink(downloaded_file) if os.path.exists(downloaded_file):
os.unlink(downloaded_file)
if not self.check_valid_image(): if not self.check_valid_image():
os.unlink(self.get_path()) os.unlink(self.get_path())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment