summaryrefslogtreecommitdiffstats
path: root/src/live
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-08-08 16:11:26 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-08-09 11:05:02 +0200
commit9fa4a5f6510c43484b879823c7e5fb6e6cff2a89 (patch)
treef79d989a756c1c6503e0e8e4234721972c541fd9 /src/live
parent73ecb48113eb8d2a37cee89e3481415089867709 (diff)
live: clean files after a failed cache image copy
Remove image files after a failed image copy operation.
Diffstat (limited to 'src/live')
-rw-r--r--src/live/ogOperations.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index b22d8b2..98528a7 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -208,6 +208,13 @@ class OgLiveOperations:
r = shutil.copy(src, dst)
tip_write_csum(image_name)
except (OSError, OgError) as e:
+ try:
+ if os.path.exists(dst):
+ os.unlink(dst)
+ if os.path.exists(f"{dst}.full.sum"):
+ os.unlink(f"{dst}.full.sum")
+ except OSError as e:
+ pass
raise OgError(f'Error copying image {image_name} to cache. Reported: {e}') from e
if (not os.path.exists(dst)):