fix top list
This commit is contained in:
parent
cb906fb82b
commit
c377709bee
@ -8,7 +8,7 @@ import auth
|
|||||||
|
|
||||||
app_config = auth.return_app_config()
|
app_config = auth.return_app_config()
|
||||||
BASE_DIR = os.path.realpath(app_config['BASE_DIR'])
|
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)
|
log_db = sqlite3.connect("access_log.db", check_same_thread=False)
|
||||||
|
|
||||||
@ -156,7 +156,13 @@ def generate_top_list(category):
|
|||||||
filelist = []
|
filelist = []
|
||||||
for record in records:
|
for record in records:
|
||||||
rel_path = record['rel_path']
|
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({
|
filelist.append({
|
||||||
'name': os.path.basename(rel_path),
|
'name': os.path.basename(rel_path),
|
||||||
'path': rel_path,
|
'path': rel_path,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user