MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / walkFolder

Function walkFolder

apps/desktop/src/main/vault.ts:2067–2096  ·  view source on GitHub ↗
(
    folder: NoteFolder,
    dirAbs: string,
    dirReal: string,
    topAbs: string,
    isPrimaryRoot: boolean,
    ancestors: Set<string>
  )

Source from the content-addressed store, hash-verified

2065async function collectBuiltinSearchCandidates(root: string): Promise<VaultTextSearchCandidate[]> {
2066 const files: Array<{ full: string; folder: NoteFolder }> = []
2067 const walkFolder = async (
2068 folder: NoteFolder,
2069 dirAbs: string,
2070 dirReal: string,
2071 topAbs: string,
2072 isPrimaryRoot: boolean,
2073 ancestors: Set<string>
2074 ): Promise<void> => {
2075 let entries: Dirent[]
2076 try {
2077 entries = await fs.readdir(dirAbs, { withFileTypes: true })
2078 } catch {
2079 return
2080 }
2081
2082 for (const entry of entries) {
2083 const full = path.join(dirAbs, entry.name)
2084 const childReal = await resolveDirDescent(full, entry, dirReal, ancestors)
2085 if (childReal !== null) {
2086 if (entry.name.startsWith('.')) continue
2087 if (isPrimaryRoot && dirAbs === topAbs && shouldHidePrimaryRootEntry(entry.name)) continue
2088 ancestors.add(childReal)
2089 await walkFolder(folder, full, childReal, topAbs, isPrimaryRoot, ancestors)
2090 ancestors.delete(childReal)
2091 continue
2092 }
2093 if (!(await isMarkdownNoteEntry(full, entry))) continue
2094 files.push({ full, folder })
2095 }
2096 }
2097
2098 for (const folder of SEARCHABLE_TEXT_FOLDERS) {
2099 const topAbs = await folderRoot(root, folder)

Callers 2

listNotesFunction · 0.85

Calls 5

resolveDirDescentFunction · 0.85
isMarkdownNoteEntryFunction · 0.85
isExcalidrawFileEntryFunction · 0.85
deleteMethod · 0.80

Tested by

no test coverage detected