mirror of https://git.48k.eu/ogclient
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.master
parent
1376b1900d
commit
1329c0955b
|
|
@ -212,15 +212,17 @@ class OgLiveOperations:
|
||||||
if not get_cache_dev_path():
|
if not get_cache_dev_path():
|
||||||
raise OgError('No cache partition is mounted')
|
raise OgError('No cache partition is mounted')
|
||||||
|
|
||||||
|
fetch = False
|
||||||
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'
|
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'
|
||||||
if (not os.path.exists(image_path) or
|
if (not os.path.exists(image_path) or not tip_check_csum(repo, name)):
|
||||||
not tip_check_csum(repo, name)):
|
|
||||||
self._copy_image_to_cache(name)
|
self._copy_image_to_cache(name)
|
||||||
|
fetch = True
|
||||||
|
|
||||||
if (not os.path.exists(image_path)):
|
if fetch:
|
||||||
raise OgError(f'could not find {image_path} in cache')
|
if (not os.path.exists(image_path)):
|
||||||
if (not tip_check_csum(repo, name)):
|
raise OgError(f'could not find {image_path} in cache')
|
||||||
raise OgError(f'Failed to validate checksum for {name}.img')
|
if (not tip_check_csum(repo, name)):
|
||||||
|
raise OgError(f'Failed to validate checksum for {name}.img')
|
||||||
else:
|
else:
|
||||||
if os.access(f'/opt/opengnsys/images', os.R_OK) == False:
|
if os.access(f'/opt/opengnsys/images', os.R_OK) == False:
|
||||||
raise OgError('Cannot access /opt/opengnsys/images in read mode, check permissions')
|
raise OgError('Cannot access /opt/opengnsys/images in read mode, check permissions')
|
||||||
|
|
@ -234,18 +236,21 @@ class OgLiveOperations:
|
||||||
if not get_cache_dev_path():
|
if not get_cache_dev_path():
|
||||||
raise OgError('No cache partition is mounted')
|
raise OgError('No cache partition is mounted')
|
||||||
|
|
||||||
|
fetch = False
|
||||||
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'
|
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'
|
||||||
try:
|
try:
|
||||||
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)):
|
||||||
tip_client_get(repo, name)
|
tip_client_get(repo, name)
|
||||||
|
fetch = True
|
||||||
except:
|
except:
|
||||||
self._restartBrowser(self._url)
|
self._restartBrowser(self._url)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if (not os.path.exists(image_path)):
|
if fetch:
|
||||||
raise OgError(f'could not find {image_path} in cache')
|
if (not os.path.exists(image_path)):
|
||||||
if (not tip_check_csum(repo, name)):
|
raise OgError(f'could not find {image_path} in cache')
|
||||||
raise OgError(f'Failed to validate checksum for {name}.img')
|
if (not tip_check_csum(repo, name)):
|
||||||
|
raise OgError(f'Failed to validate checksum for {name}.img')
|
||||||
|
|
||||||
self._restore_image(image_path, devpath)
|
self._restore_image(image_path, devpath)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue