summaryrefslogtreecommitdiff
path: root/morphlib/exts/rawdisk.write
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/exts/rawdisk.write')
-rwxr-xr-xmorphlib/exts/rawdisk.write3
1 files changed, 2 insertions, 1 deletions
diff --git a/morphlib/exts/rawdisk.write b/morphlib/exts/rawdisk.write
index bde9d67d..87edf7bf 100755
--- a/morphlib/exts/rawdisk.write
+++ b/morphlib/exts/rawdisk.write
@@ -50,9 +50,10 @@ class RawDiskWriteExtension(morphlib.writeexts.WriteExtension):
self.create_local_system(temp_root, location)
self.status(msg='Disk image has been created at %s' % location)
except Exception:
- os.remove(location)
self.status(msg='Failure to create disk image at %s' %
location)
+ if os.path.exists(location):
+ os.remove(location)
raise
def upgrade_local_system(self, raw_disk, temp_root):