From 7801d483d453dcc47b36429cc763fb5908c7a21b Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 7 Feb 2023 10:16:06 +0100 Subject: utils: add init_cache function init_cache() creates the default directory in which OpenGnsys stores images when using any cache enabled transfer method. As of this commit this folder must exist for tiptorrent.py to work properly. Subprocess Popen object inside tiptorrent.py use 'cwd' optional parameter like: cwd='/opt/opengnsys/cache/opt/opengnsys/images/' This folder convention might change in the future. --- src/utils/cache.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/utils/cache.py b/src/utils/cache.py index 3bd4053..9952c50 100644 --- a/src/utils/cache.py +++ b/src/utils/cache.py @@ -68,3 +68,15 @@ 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.debug(f'Creating cache directory at {mountpoint}') + os.makedirs('/opt/opengnsys/cache/opt/opengnsys/images') -- cgit v1.2.3-18-g5258