Skip to content

Only skip descendants on directories in fetchAllDirectories - #2055

Open
mvanhorn wants to merge 1 commit into
glushchenko:masterfrom
mvanhorn:fix/2054-nested-folders-skip-descendants
Open

mvanhorn wants to merge 1 commit into
glushchenko:masterfrom
mvanhorn:fix/2054-nested-folders-skip-descendants

Conversation

@mvanhorn

Copy link
Copy Markdown

Motivation

Nested subfolders can disappear from the sidebar after restarting FSNotes, even though their notes remain indexed and searchable. Subfolders created during a session show up immediately but vanish on the next launch.

Project.fetchAllDirectories() and Storage.fetchAllDirectories(url:) called fileEnumerator.skipDescendants() whenever an item matched the excluded extensions or path filters, including regular files like .md or .png. Calling skipDescendants() on a non-directory makes FileManager.DirectoryEnumerator skip the rest of the parent directory, dropping subsequent subdirectories and their subtrees.

Summary

Both fetchAllDirectories methods in FSNotesCore/Business/Project.swift and FSNotesCore/Business/Storage.swift now prefetch .isDirectoryKey and .isPackageKey and skip non-directories before evaluating exclusions, so skipDescendants() is only called on directories and packages. Valid directories are collected directly in that single pass up to maxDirs (preserving the hidden-directory check in Project.swift), removing the second pass.

How it was tested

No local test run is recorded for the fsnotes Project: change to FSNotesCore/Business/Project.swift and FSNotesCore/Business/Storage.swift.

Fixes #2054

Both `fetchAllDirectories` methods in
`FSNotesCore/Business/Project.swift` and
`FSNotesCore/Business/Storage.swift` now prefetch `.isDirectoryKey` and
`.isPackageKey` and skip non-directories before evaluating exclusions,
so `skipDescendants()` is only called on directories and packages. Valid
directories are collected directly in that single pass up to `maxDirs`
(preserving the hidden-directory check in `Project.swift`), removing the
second pass.

Fixes glushchenko#2054

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7.6.0 regression: nested folders (3+ levels) disappear from sidebar after restart

1 participant