From 696a8e1bf94a223399ad12f42d8e6e09da0bb9ca Mon Sep 17 00:00:00 2001 From: TailScan Bot Date: Thu, 2 Apr 2026 17:13:55 +0000 Subject: [PATCH] fix: include ancestor entries in open response to keep tree visible When navigating into a subfolder elFinder removes tree nodes for any directory not present in the files array. Include all ancestor path entries so the sidebar tree stays populated. --- main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 7340bd1..46f1558 100644 --- a/main.py +++ b/main.py @@ -986,6 +986,19 @@ async def elfinder_connector(request: Request): except Exception as e: return err(str(e)) + # Build ancestor entries so the tree sidebar stays populated. + # elFinder removes tree nodes for any dir not present in the files array. + ancestors = [] + if path != "/": + parts = path.strip("/").split("/") + for i in range(len(parts)): + anc_path = "/" + "/".join(parts[:i+1]) + if anc_path == path: + continue # already in files as cwd + anc_name = parts[i] + ancestors.append(_elf_entry(proto, host, port, share, + anc_path, anc_name, True)) + # Always include options — elFinder needs them on every open to # correctly assign files to the right volume/pane vol_options = { @@ -1001,7 +1014,7 @@ async def elfinder_connector(request: Request): } resp = { "cwd": cwd, - "files": [cwd] + files, + "files": ancestors + [cwd] + files, "api": "2.1", "uplMaxSize": "256M", "uplMaxFile": 20,