From 983da3632956384ab32ee56fe8e0b73371d16491 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Sat, 29 Oct 2022 09:55:30 +0200 Subject: [PATCH] Create tmp folder in root if it doesn't exist Fixes extension installation on Linux, closes #46 --- scripts/tag_autocomplete_helper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/tag_autocomplete_helper.py b/scripts/tag_autocomplete_helper.py index a149421..1969fbe 100644 --- a/scripts/tag_autocomplete_helper.py +++ b/scripts/tag_autocomplete_helper.py @@ -38,7 +38,8 @@ def find_ext_wildcard_paths(): WILDCARD_EXT_PATHS = find_ext_wildcard_paths() # The path to the temporary files -TEMP_PATH = TAGS_PATH.joinpath('temp') +STATIC_TEMP_PATH = FILE_DIR.joinpath('tmp') # In the webui root, on windows it exists by default, on linux it doesn't +TEMP_PATH = TAGS_PATH.joinpath('temp') # Extension specific temp files def get_wildcards(): @@ -69,7 +70,7 @@ def get_embeddings(): def write_tag_base_path(): """Writes the tag base path to a fixed location temporary file""" - with open(FILE_DIR.joinpath('tmp/tagAutocompletePath.txt'), 'w', encoding="utf-8") as f: + with open(STATIC_TEMP_PATH.joinpath('tagAutocompletePath.txt'), 'w', encoding="utf-8") as f: f.write(TAGS_PATH.relative_to(FILE_DIR).as_posix()) @@ -81,6 +82,9 @@ def write_to_temp_file(name, data): # Write the tag base path to a fixed location temporary file # to enable the javascript side to find our files regardless of extension folder name +if not STATIC_TEMP_PATH.exists(): + STATIC_TEMP_PATH.mkdir(exist_ok=True) + write_tag_base_path() # Check if the temp path exists and create it if not