( root: string, topFolder: NoteFolder, subpath: string )
| 3444 | * top-level `inbox`/`archive`/`trash` folders themselves. |
| 3445 | */ |
| 3446 | export async function deleteFolder( |
| 3447 | root: string, |
| 3448 | topFolder: NoteFolder, |
| 3449 | subpath: string |
| 3450 | ): Promise<void> { |
| 3451 | const clean = subpath.replace(/^\/+|\/+$/g, '') |
| 3452 | if (!clean) throw new Error('Cannot delete the top-level folder') |
| 3453 | const abs = resolveSafe(await folderRoot(root, topFolder), clean) |
| 3454 | await fs.rm(abs, { recursive: true, force: true }) |
| 3455 | const settings = await getVaultSettings(root) |
| 3456 | const nextSettings: VaultSettings = { |
| 3457 | ...settings, |
| 3458 | folderIcons: removeFolderIcons(settings.folderIcons, topFolder, clean), |
| 3459 | folderColors: removeFolderColors(settings.folderColors, topFolder, clean) |
| 3460 | } |
| 3461 | await setVaultSettings(root, nextSettings) |
| 3462 | invalidateNoteMetaCache(root) |
| 3463 | invalidateVaultTextSearchCache(root) |
| 3464 | } |
| 3465 | |
| 3466 | /** |
| 3467 | * Duplicate a subfolder (recursively, with all its contents) next to |
no test coverage detected