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

Function importExternalNote

apps/desktop/src/main/vault.ts:3091–3105  ·  view source on GitHub ↗
(root: string, sourceAbsPath: string)

Source from the content-addressed store, hash-verified

3089 * file is removed once copied. Returns the new note's metadata.
3090 */
3091export async function importExternalNote(root: string, sourceAbsPath: string): Promise<NoteMeta> {
3092 const source = path.resolve(sourceAbsPath)
3093 const destDir = await folderRoot(root, 'inbox')
3094 await fs.mkdir(destDir, { recursive: true })
3095 const baseTitle = path.basename(source, path.extname(source)) || 'Untitled'
3096 const finalTitle = await uniqueTitle(destDir, baseTitle)
3097 const destAbs = path.join(destDir, `${finalTitle}.md`)
3098 const body = await fs.readFile(source, 'utf8')
3099 await fs.writeFile(destAbs, body, 'utf8')
3100 await fs.rm(source, { force: true })
3101 const rel = toPosix(path.relative(root, destAbs))
3102 invalidateNoteMetaCache(root, rel)
3103 invalidateVaultTextSearchCache(root)
3104 return await readMeta(root, destAbs, folderForRelativePath(rel) ?? 'inbox')
3105}
3106
3107export async function renameNote(
3108 root: string,

Callers 1

registerIpcFunction · 0.90

Calls 7

invalidateNoteMetaCacheFunction · 0.85
folderForRelativePathFunction · 0.85
folderRootFunction · 0.70
uniqueTitleFunction · 0.70
toPosixFunction · 0.70
readMetaFunction · 0.70

Tested by

no test coverage detected