Load the folder-access editor lazily to fix multi-minute freeze on large libraries#116
Open
janpospis wants to merge 2 commits into
Open
Load the folder-access editor lazily to fix multi-minute freeze on large libraries#116janpospis wants to merge 2 commits into
janpospis wants to merge 2 commits into
Conversation
…rants The admin folder-access matrix and the folder-list endpoint pulled the entire folder tree recursively (FolderModel::getSubfolders), which is O(n) over the whole library and froze the UI for minutes on large trees. - getFolderList: default to a shallow top-level listing when no folder= is given; the full recursive list is still available via &deep=1. - getUserGrants: read grants straight from folder_acl.json (the only folders that can carry a grant) instead of walking every folder. getGrants runs once per user, so this was the dominant cost. Measured on a ~50k-folder library: getUserGrants ~239s -> ~0.006s. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The folder-access editor loaded the whole folder tree up front and rendered one row per folder, freezing on large libraries. Load one level at a time (shallow) and add a breadcrumb plus per-row drill-in to reach subfolders. In-progress edits are collected into the fallback map before navigating, so the batched save still persists grants from every visited level. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
janpospis
force-pushed
the
fix/lazy-acl-folder-loading
branch
2 times, most recently
from
July 22, 2026 20:46
59eb54a to
515ff52
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a large library, loading the folder list freezes for minutes. It is most visible in the admin Folder access editor (the user × folder permission matrix), but it also affects other places that request the full folder list (the file browser's startup default-folder detection, the "move to folder" picker, portals).
Root cause
getFolderList.php(viaFolderModel::getFolderList()→getSubfolders()) does a full recursive walk of the whole tree when nofolder=is given — O(n) over the entire library. Several callers hit this:AclAdminController::getUserGrants()— calls it with no arguments once per user, so it dominates the matrix load,On a ~50k-folder library,
getUserGrants('<user>')measured ~239 s; the walk returned 50,293 folders in 239 s vs 24 top-level folders in 0.11 s.Changes
FolderController::getFolderList— when no explicitfolder=is given, default to a shallow (top-level) listing instead of the full recursive walk. This fixes every caller that pulled the whole list at once. The full recursive list is still available via&deep=1, and directory navigation (which passes an explicitfolder=) is unaffected.AclAdminController::getUserGrants— read grants directly fromfolder_acl.json(the only folders that can carry a grant) instead of walking the tree. ~239 s → ~0.006 s.adminFolderAccess.js— the folder-access editor now loads one level at a time (using the shallowfolder=<path>mode) with a breadcrumb and per-row drill-in to reach and set permissions on subfolders. In-progress edits are collected into the existing fallback map before navigating, so the batched save still persists grants from every visited level.Notes
&deep=1where needed. On large libraries the full flat list was effectively unusable anyway.open_subfolders(falls back to "Open subfolders").Testing
Verified on a ~50k-folder local library: the folder-access editor and folder-list loading no longer freeze, drill-in reaches subfolders, and saving persists grants set across multiple levels.