limit folder_today to actual available folder

This commit is contained in:
lelo 2025-05-20 20:47:32 +00:00
parent b518b61a64
commit 2c340ae2df

View File

@ -158,6 +158,25 @@ def log_file_access(rel_path, filesize, mime, ip_address, user_agent, device_id,
return True
def return_folder_today():
"""
Return only those folder_today entries whose first segment
(up to the first '/') is in session['folders'].keys().
"""
valid_keys = set(session.get('folders', {}).keys())
filtered = []
for entry in folder_today:
# get the part before the first slash
top_level = entry['rel_path'].split('/', 1)[0]
# include only if this segment is one of the session keys
if top_level in valid_keys:
filtered.append(entry)
return filtered
def return_file_access():
"""Return recent file access logs from memory (the last 10 minutes)."""
global file_access_temp
@ -174,13 +193,6 @@ def return_file_access():
return []
def return_folder_today():
global folder_today
if folder_today:
return folder_today
else:
return []
def songs_dashboard():
# — SESSION & PARAM HANDLING (unchanged) —
if 'songs_dashboard_timeframe' not in session: