From 25b00bfd6985a4d35deed2cc25f2abbd62967b0e Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 27 Mar 2024 09:58:13 +0100 Subject: live: use .ant image as main image after image creation error Restore image file from .ant to original file name if new image creation fails. Remove new imagen and move the .ant image file in place of the original as previously an error meant a rename of the image file without a revert to keep the image available. --- src/live/ogOperations.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index a3df4c8..08c2f5d 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -504,6 +504,12 @@ class OgLiveOperations: image_info = ogGetImageInfo(image_path) except Exception as e: + if os.path.exists(image_path): + os.unlink(image_path) + + if os.path.exists(f'{image_path}.ant'): + shutil.move(f'{image_path}.ant', image_path) + self._restartBrowser(self._url) raise RuntimeError(f'Failed to create image for {fstype} filesystem in device {padev}: {e}') from e -- cgit v1.2.3-18-g5258