From 1376b1900d6bda4cbf7c9082e7cd201f6abcbab0 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Tue, 30 Jul 2024 09:30:44 +0200 Subject: live: remove old image and checksum file on download Restoring an updated image file (with different checksum) could fail while the old checksum file could remain in place. Remove image and checksum file before fetching the new files. --- src/live/ogOperations.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/live') diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index 7bb2528..d77fe65 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -185,8 +185,16 @@ class OgLiveOperations: Implies a unicast transfer. Does not use tiptorrent. """ - src = f'/opt/opengnsys/images/{image_name}.img' dst = f'{OG_CACHE_IMAGE_PATH}{image_name}.img' + 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: + raise OgError(f"Error deleting file {e.filename}: {e.strerror}") from e + + src = f'/opt/opengnsys/images/{image_name}.img' try: logging.info(f'Fetching image {image_name} from {src}') logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time') -- cgit v1.2.3-18-g5258