server-ts: Address requested changes

This commit is contained in:
Elian Doran
2024-04-13 17:30:48 +03:00
parent 1ac65fff47
commit a66e4435ba
6 changed files with 12 additions and 15 deletions

View File

@@ -35,8 +35,8 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
// path => noteId, used only when meta file is not available
/** path => noteId | attachmentId */
const createdPaths: Record<string, string> = { '/': importRootNote.noteId, '\\': importRootNote.noteId };
let metaFile!: MetaFile;
let firstNote!: BNote;
let metaFile: MetaFile | null = null;
let firstNote: BNote | null = null;
const createdNoteIds = new Set<string>();
function getNewNoteId(origNoteId: string) {
@@ -99,7 +99,7 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
dataFileName: ""
};
let parent!: NoteMeta;
let parent: NoteMeta | undefined = undefined;
for (const segment of pathSegments) {
if (!cursor?.children?.length) {
@@ -590,6 +590,10 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
}
}
if (!firstNote) {
throw new Error("Unable to determine first note.");
}
return firstNote;
}