(root: string, rel: string)
| 3687 | } |
| 3688 | |
| 3689 | export async function duplicateNote(root: string, rel: string): Promise<NoteMeta> { |
| 3690 | const abs = resolveSafe(root, rel) |
| 3691 | const folder = folderOf(root, abs) |
| 3692 | if (!folder) throw new Error(`Note not in a known folder: ${rel}`) |
| 3693 | const dir = path.dirname(abs) |
| 3694 | const ext = path.extname(abs) |
| 3695 | const baseTitle = path.basename(abs, ext) |
| 3696 | const copyTitle = await uniqueTitle(dir, `${baseTitle} copy`) |
| 3697 | const destAbs = path.join(dir, `${copyTitle}${ext}`) |
| 3698 | const body = await fs.readFile(abs, 'utf8') |
| 3699 | await fs.writeFile(destAbs, body, 'utf8') |
| 3700 | const meta = await readMeta(root, destAbs, folder) |
| 3701 | await copyNoteComments(root, rel, meta.path) |
| 3702 | invalidateNoteMetaCache(root, meta.path) |
| 3703 | invalidateVaultTextSearchCache(root) |
| 3704 | return meta |
| 3705 | } |
| 3706 | |
| 3707 | export async function importFiles( |
| 3708 | root: string, |
no test coverage detected