diff options
-rw-r--r-- | src/utils/cache.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/utils/cache.py b/src/utils/cache.py index b60b5be..374f8e0 100644 --- a/src/utils/cache.py +++ b/src/utils/cache.py @@ -13,8 +13,9 @@ from src.utils.fs import mount_mkdir, umount from src.utils.net import getifaddr from src.utils.probe import get_cache_dev_path -OGIMG='/opt/opengnsys/images/' -OGCACHE_MOUNTPOINT='/opt/opengnsys/cache' +OG_IMAGE_PATH = '/opt/opengnsys/images/' +OG_CACHE_PATH = '/opt/opengnsys/cache' +OG_CACHE_IMAGE_PATH = OG_CACHE_PATH + OG_IMAGE_PATH OGCLIENT_LOG_CACHE='/opt/opengnsys/log/{ip}.cache.txt' def mount_cache(): @@ -27,18 +28,18 @@ def mount_cache(): if cache_dev: # cache_target = cache_dev.replace('dev', 'mnt') - mount_mkdir(cache_dev, OGCACHE_MOUNTPOINT) - return OGCACHE_MOUNTPOINT + mount_mkdir(cache_dev, OG_CACHE_PATH) + return OG_CACHE_PATH return '' def umount_cache(): """ - If OGCACHE_MOUNTPOINT is a mountpoint, umounts. + If OG_CACHE_PATH is a mountpoint, umounts. If not, does nothing. """ - if os.path.ismount(OGCACHE_MOUNTPOINT): - umount(OGCACHE_MOUNTPOINT) + if os.path.ismount(OG_CACHE_PATH): + umount(OG_CACHE_PATH) def write_cache_txt(content): """ @@ -63,7 +64,7 @@ def generate_cache_txt(): if cache_path: try: - files = os.listdir(f'{cache_path}{OGIMG}') + files = os.listdir(f'{cache_path}{OG_IMAGE_PATH}') except FileNotFoundError: return content = ','.join(files) |