Skip to content

fix(folderwatcher): do not walk or list the content of excluded folders - #11372

Open
v3DJG6GL wants to merge 2 commits into
nextcloud:masterfrom
v3DJG6GL:fix/folderwatcher-skip-ignored-folders
Open

v3DJG6GL wants to merge 2 commits into
nextcloud:masterfrom
v3DJG6GL:fix/folderwatcher-skip-ignored-folders

Conversation

@v3DJG6GL

@v3DJG6GL v3DJG6GL commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Resolves

Resolves #11371

Summary

  • with virtual files (OpenVFS) enabled on Linuy, large excluded folders can cause freezes of the UI: ~50 s at startup and ~30–45 s after pause sync for all → resume sync for all
  • Issue No. 1: Linux watcher (findFoldersBelow) walks + watches every subfolder incl. excluded ones - on the UI thread and through FUSE.
  • Issue No. 2: A change on an excluded folder itself (pin state written) → changeDetected lists its whole content (appendSubPaths) → all~48'000 paths run through ignore- and lock-file checks on the UI thread.

Change

  • Commit 1 (Linux only): excluded folders and their content are neither walked nor watched.
  • Commit 2 (shared code, Linux + Windows; macOS unchanged): a change on an excluded folder reports only the folder itself.
  • The excluded folder itself is still reported → Folder still sets PinState Excluded (76376aa, [Bug]: ignored files always show state 'sync pending' #5524/[Bug]: Nextcloud VFS on Windows always displays "syncing" icon for .lnk files #5594 keep working)
  • Folder now hands the exclude check to the watcher via setFolderExcludedCheck(). Tests use the same mechanism, since Folder' check is turned off in test builds.
  • known limitation: a folder removed from the exclude list while the client runs is watched only after a restart; the periodic full local discovery covers it until then

Results (same machine, OpenVFS)

Before After
watcher at startup, all 5 sync folders ~50 s (Documents alone 49,5 s) 1,5 s
"Ignoring file" log lines ~48'000 per resume 105 in the whole run
freeze after pause → resume 30-45 s none noticeable

Tests

  • new: testExcludedFolderIsNotWatched, testCreatedExcludedFolderIsNotWatched, testChangeOnExcludedFolderDoesNotListItsContent
  • all 3 fail without the fix (7 instead of 3 watches / 6 instead of 3 / content of the excluded folder listed)
  • Linux: These tests pass: FolderWatcherTest 19/19, InotifyWatcherTest 4/4, FolderWatcherChangeDetectionTest 5/5 (1 skip), FolderTest 3/3, FolderManTest 10/10
  • Windows: FolderWatcherTest is disabled on Windows upstream (a3083f8) → only build + other tests via CI [WINDOWS-CI IS PENDING]
  • macOS: not affected by this PR

Lines changed

Category Added Removed
Code 22 3
Comments 2 0
Tests 73 0

TODO

  • Linux Tests (CachyOS)
  • Windows Tests

Checklist

AI (if applicable)

LLM Disclosure

  • Developed with assistance from Claude Code (Opus 5.5). The LLM helped me identify the related files, code parts and proposed possible code modifications and fixes.
  • I've reviewed, cleaned, refactored and hardened the code the best I could.

At start the Linux folder watcher listed every folder below the sync
root and registered an inotify watch for it, including folders on the
exclude list. With large excluded folders, such as repositories kept
next to synced files, this blocked the client for close to a minute,
more so with virtual files where each listing goes through FUSE.

Excluded folders are now neither walked nor watched. Changes to the
excluded folder itself are still reported, and its content inherits its
exclusion. A folder removed from the exclude list while the client runs
is watched after the next start of the client and picked up by the full
local discovery until then.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: v3DJG6GL <72495210+v3DJG6GL@users.noreply.github.com>
…anges

A change on a folder reported every path below it. When the client
wrote the pin state of an excluded folder, the attribute change listed
its whole content, tens of thousands of paths for large excluded
folders, and each of them went through the ignore check on the main
thread. A change on an excluded folder now reports only the folder.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: v3DJG6GL <72495210+v3DJG6GL@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant