server: Refactor variable usage

This commit is contained in:
Elian Doran 2024-10-10 20:19:59 +03:00
parent c37a51c6d0
commit 5e80f120c9
No known key found for this signature in database

View File

@ -456,8 +456,8 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
return; return;
} }
let { mime, type } = noteMeta ? noteMeta : detectFileTypeAndMime(taskContext, filePath); let { mime, type: detectedType } = noteMeta ? noteMeta : detectFileTypeAndMime(taskContext, filePath);
type = resolveNoteType(type); const type = resolveNoteType(detectedType);
if (mime == null) { if (mime == null) {
throw new Error("Unable to resolve mime type."); throw new Error("Unable to resolve mime type.");
} }
@ -478,7 +478,7 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
// only skeleton was created because of altered order of cloned notes in ZIP, we need to update // only skeleton was created because of altered order of cloned notes in ZIP, we need to update
// https://github.com/zadam/trilium/issues/2440 // https://github.com/zadam/trilium/issues/2440
if (note.type === undefined) { if (note.type === undefined) {
note.type = type as NoteType; note.type = type;
note.mime = mime; note.mime = mime;
note.title = noteTitle || ""; note.title = noteTitle || "";
note.isProtected = isProtected; note.isProtected = isProtected;
@ -503,7 +503,7 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
title: noteTitle || "", title: noteTitle || "",
content: content, content: content,
noteId, noteId,
type: type as NoteType, type,
mime, mime,
prefix: noteMeta?.prefix || '', prefix: noteMeta?.prefix || '',
isExpanded: !!noteMeta?.isExpanded, isExpanded: !!noteMeta?.isExpanded,