diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-10-04 10:15:57 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-10-08 10:07:45 +0200 |
commit | f942b19eae90e9ca468cbe0a93e5dc9ad02b38d0 (patch) | |
tree | 2342c2426a3e77829c712fad5476e13776419fae /src/utils | |
parent | fe960010a06471eefc2ffebc1d8bbd06f09b98c4 (diff) |
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().
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/cache.py | 23 |
1 files changed, 4 insertions, 19 deletions
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') |