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

Function duplicateNote

apps/desktop/src/mcp/vault-ops.ts:716–728  ·  view source on GitHub ↗
(root: string, rel: string)

Source from the content-addressed store, hash-verified

714}
715
716export async function duplicateNote(root: string, rel: string): Promise<NoteMeta> {
717 const abs = resolveSafe(root, rel)
718 const folder = folderOf(root, abs)
719 if (!folder) throw new Error(`Note not in a known folder: ${rel}`)
720 const dir = path.dirname(abs)
721 const ext = path.extname(abs)
722 const baseTitle = path.basename(abs, ext)
723 const copyTitle = await uniqueTitle(dir, `${baseTitle} copy`)
724 const destAbs = path.join(dir, `${copyTitle}${ext}`)
725 const body = await fs.readFile(abs, 'utf8')
726 await fs.writeFile(destAbs, body, 'utf8')
727 return await readMeta(root, destAbs, folder)
728}
729
730export async function deleteNote(root: string, rel: string): Promise<void> {
731 const abs = resolveSafe(root, rel)

Callers 1

server.tsFile · 0.70

Calls 4

resolveSafeFunction · 0.70
folderOfFunction · 0.70
uniqueTitleFunction · 0.70
readMetaFunction · 0.70

Tested by

no test coverage detected