MCPcopy Index your code
hub / github.com/massCodeIO/massCode / ensureFolderPath

Function ensureFolderPath

src/main/import/notes/persist.ts:89–112  ·  view source on GitHub ↗
(
  rootFolderId: number,
  folderPath: string[] | undefined,
)

Source from the content-addressed store, hash-verified

87}
88
89function ensureFolderPath(
90 rootFolderId: number,
91 folderPath: string[] | undefined,
92): { created: number, folderId: number } {
93 const storage = useNotesStorage()
94 let created = 0
95 let parentId = rootFolderId
96
97 for (const part of folderPath || []) {
98 const name = normalizeImportEntryName(part, 'Imported')
99 const folders = storage.folders.getFolders()
100 const existingId = findFolderId(folders, parentId, name)
101
102 if (existingId !== null) {
103 parentId = existingId
104 continue
105 }
106
107 parentId = storage.folders.createFolder({ name, parentId }).id
108 created += 1
109 }
110
111 return { created, folderId: parentId }
112}
113
114function getOrCreateTagIds(tags: string[] | undefined): {
115 created: number

Callers 1

applyNotesImportResultFunction · 0.70

Calls 3

useNotesStorageFunction · 0.90
normalizeImportEntryNameFunction · 0.90
findFolderIdFunction · 0.70

Tested by

no test coverage detected