From f942b19eae90e9ca468cbe0a93e5dc9ad02b38d0 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 4 Oct 2024 10:15:57 +0200 Subject: src: fix cache mount in new ogLive Mount cache in image_create() image_restore() and cache_fetch(). Remove init_cache() and ensure /opt/opengnsys/images/ exists within the cache mountpoint if it does not exists in cache_mount(). --- src/utils/cache.py | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'src/utils/cache.py') diff --git a/src/utils/cache.py b/src/utils/cache.py index 6358c6a..ea32f8b 100644 --- a/src/utils/cache.py +++ b/src/utils/cache.py @@ -19,16 +19,13 @@ OG_CACHE_IMAGE_PATH = OG_CACHE_PATH + OG_IMAGE_PATH OGCLIENT_LOG_CACHE='/opt/opengnsys/log/{ip}.cache.txt' def mount_cache(): - """ - Probes for cache and mounts if succesful. - - Returns the mountpoint or an empty string. - """ cache_dev = get_cache_dev_path() if cache_dev: - # cache_target = cache_dev.replace('dev', 'mnt') - mount_mkdir(cache_dev, OG_CACHE_PATH) + cache_mounted = mount_mkdir(cache_dev, OG_CACHE_PATH) + + if cache_mounted and not os.path.exists(OG_CACHE_IMAGE_PATH): + os.makedirs(OG_CACHE_IMAGE_PATH) return OG_CACHE_PATH return '' @@ -69,15 +66,3 @@ def generate_cache_txt(): return content = ','.join(files) write_cache_txt(content) - - -def init_cache(): - """ - If a cache partition is present, creates the following directories - /opt/opengnsys/images. This is the default folder in which images - are stored when using tiptorrent-cache. - """ - mountpoint = mount_cache() - if mountpoint: - logging.info(f'Creating cache directory at {mountpoint}') - os.makedirs(f'{mountpoint}/opt/opengnsys/images') -- cgit v1.2.3-18-g5258