From 9fa4a5f6510c43484b879823c7e5fb6e6cff2a89 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 8 Aug 2024 16:11:26 +0200 Subject: live: clean files after a failed cache image copy Remove image files after a failed image copy operation. --- src/live/ogOperations.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') 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)): -- cgit v1.2.3-18-g5258