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

Function duplicateNote

apps/desktop/src/main/vault.ts:3689–3705  ·  view source on GitHub ↗
(root: string, rel: string)

Source from the content-addressed store, hash-verified

3687}
3688
3689export 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
3707export async function importFiles(
3708 root: string,

Callers 2

registerIpcFunction · 0.90
cmdDuplicateFunction · 0.50

Calls 7

copyNoteCommentsFunction · 0.85
invalidateNoteMetaCacheFunction · 0.85
resolveSafeFunction · 0.70
folderOfFunction · 0.70
uniqueTitleFunction · 0.70
readMetaFunction · 0.70

Tested by

no test coverage detected