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

Function moveNoteComments

apps/desktop/src/main/vault.ts:2750–2772  ·  view source on GitHub ↗
(root: string, oldRel: string, nextRel: string)

Source from the content-addressed store, hash-verified

2748}
2749
2750async function moveNoteComments(root: string, oldRel: string, nextRel: string): Promise<void> {
2751 const oldAbs = noteCommentsPath(root, oldRel)
2752 const nextAbs = noteCommentsPath(root, nextRel)
2753 if (oldAbs === nextAbs) return
2754 try {
2755 await fs.access(oldAbs)
2756 } catch {
2757 return
2758 }
2759 await fs.mkdir(path.dirname(nextAbs), { recursive: true })
2760 try {
2761 await fs.access(nextAbs)
2762 const [existing, moving] = await Promise.all([
2763 readNoteComments(root, nextRel),
2764 readNoteComments(root, oldRel)
2765 ])
2766 await writeNoteComments(root, nextRel, [...existing, ...moving])
2767 await fs.rm(oldAbs, { force: true })
2768 } catch (err) {
2769 if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err
2770 await fs.rename(oldAbs, nextAbs)
2771 }
2772}
2773
2774async function copyNoteComments(root: string, sourceRel: string, nextRel: string): Promise<void> {
2775 const source = await readNoteComments(root, sourceRel)

Callers 3

renameNoteFunction · 0.85
moveBetweenFoldersFunction · 0.85
moveNoteFunction · 0.85

Calls 3

noteCommentsPathFunction · 0.85
readNoteCommentsFunction · 0.70
writeNoteCommentsFunction · 0.70

Tested by

no test coverage detected