diff --git a/helperfunctions.py b/helperfunctions.py index ca8ab6c..a63dac9 100644 --- a/helperfunctions.py +++ b/helperfunctions.py @@ -8,7 +8,7 @@ import auth app_config = auth.return_app_config() BASE_DIR = os.path.realpath(app_config['BASE_DIR']) -CATEGORY_KEYWORDS = os.path.realpath(app_config['CATEGORY_KEYWORDS']) +CATEGORY_KEYWORDS = app_config['CATEGORY_KEYWORDS'] log_db = sqlite3.connect("access_log.db", check_same_thread=False) @@ -156,7 +156,13 @@ def generate_top_list(category): filelist = [] for record in records: rel_path = record['rel_path'] - if os.path.exists(os.path.join(BASE_DIR, rel_path)): # ensure file exists on disk // slow operation. maybe improve later + + # Locate the real file on disk + root, *relative_parts = rel_path.split('/') + base_path = session['folders'].get(root) + full_path = os.path.join(base_path or '', *relative_parts) + + if os.path.exists(os.path.join(BASE_DIR, full_path)): # ensure file exists on disk // slow operation. maybe improve later filelist.append({ 'name': os.path.basename(rel_path), 'path': rel_path,