live: handle no cache in tiptorrent and unicast restore

Properly report the lack of cache partition when restoring an
image using TIPTORRENT and UNICAST as methods.
Abort any restore in case of no cache partition.
master v1.3.2-11
Alejandro Sirgo Rica 2024-06-06 17:13:24 +02:00
parent ec132cfb95
commit 399a5dceb8
1 changed files with 4 additions and 1 deletions

View File

@ -193,6 +193,9 @@ class OgLiveOperations:
raise OgError(f'Cannot change repository to {repo}')
if cache:
if not get_cache_dev_path():
raise OgError('No cache partition is mounted')
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'
if (not os.path.exists(image_path) or
not tip_check_csum(repo, name)):
@ -202,7 +205,7 @@ class OgLiveOperations:
self._restore_image(image_path, devpath)
def _restore_image_tiptorrent(self, repo, name, devpath):
if not os.path.exists(OG_CACHE_IMAGE_PATH):
if not get_cache_dev_path():
raise OgError('No cache partition is mounted')
image_path = f'{OG_CACHE_IMAGE_PATH}{name}.img'