summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-30 16:15:20 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-07-30 16:19:03 +0200
commit1329c0955bfed81556073bccefd7844847632544 (patch)
treebcc756cb4bcb83cafcdc0b94f17e1e85eed4d31f /src
parent1376b1900d6bda4cbf7c9082e7cd201f6abcbab0 (diff)
live: validate checksum only once if image is already in cache
if image already exists in the cache, skip a second checksum validation. log shows duplicated entries: Verifying checksum for example.img, please wait... Checksum is OK for example.img Verifying checksum for example.img, please wait... Checksum is OK for example.img because tip_check_csum() is called twice in this case.
Diffstat (limited to 'src')
-rw-r--r--src/live/ogOperations.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index d77fe65..8505beb 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -212,15 +212,17 @@ class OgLiveOperations:
if not get_cache_dev_path():
raise OgError('No cache partition is mounted')
+ fetch = False
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'
- if (not os.path.exists(image_path) or
- not tip_check_csum(repo, name)):
+ if (not os.path.exists(image_path) or not tip_check_csum(repo, name)):
self._copy_image_to_cache(name)
+ fetch = True
- if (not os.path.exists(image_path)):
- raise OgError(f'could not find {image_path} in cache')
- if (not tip_check_csum(repo, name)):
- raise OgError(f'Failed to validate checksum for {name}.img')
+ if fetch:
+ if (not os.path.exists(image_path)):
+ raise OgError(f'could not find {image_path} in cache')
+ if (not tip_check_csum(repo, name)):
+ raise OgError(f'Failed to validate checksum for {name}.img')
else:
if os.access(f'/opt/opengnsys/images', os.R_OK) == False:
raise OgError('Cannot access /opt/opengnsys/images in read mode, check permissions')
@@ -234,18 +236,21 @@ class OgLiveOperations:
if not get_cache_dev_path():
raise OgError('No cache partition is mounted')
+ fetch = False
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'
try:
if (not os.path.exists(image_path) or not tip_check_csum(repo, name)):
tip_client_get(repo, name)
+ fetch = True
except:
self._restartBrowser(self._url)
raise
- if (not os.path.exists(image_path)):
- raise OgError(f'could not find {image_path} in cache')
- if (not tip_check_csum(repo, name)):
- raise OgError(f'Failed to validate checksum for {name}.img')
+ if fetch:
+ if (not os.path.exists(image_path)):
+ raise OgError(f'could not find {image_path} in cache')
+ if (not tip_check_csum(repo, name)):
+ raise OgError(f'Failed to validate checksum for {name}.img')
self._restore_image(image_path, devpath)