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.
master
Alejandro Sirgo Rica 2024-03-27 09:58:13 +01:00
parent c3ce5342c9
commit 25b00bfd69
1 changed files with 6 additions and 0 deletions

View File

@ -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