(root: string, sourceAbsPath: string)
| 3089 | * file is removed once copied. Returns the new note's metadata. |
| 3090 | */ |
| 3091 | export 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 | |
| 3107 | export async function renameNote( |
| 3108 | root: string, |
no test coverage detected