Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve MIME type not being used when creating new note correctly, upon zip import #458

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/services/import/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,12 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
return;
}

let { mime } = noteMeta ? noteMeta : detectFileTypeAndMime(taskContext, filePath);
let { mime, type } = noteMeta ? noteMeta : detectFileTypeAndMime(taskContext, filePath);
type = resolveNoteType(type);
if (mime == null) {
throw new Error("Unable to resolve mime type.");
}

let type = resolveNoteType(noteMeta?.type);

if (type !== 'file' && type !== 'image') {
content = content.toString("utf-8");
}
Expand All @@ -479,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
// https://github.com/zadam/trilium/issues/2440
if (note.type === undefined) {
note.type = type;
note.type = type as NoteType;
note.mime = mime;
note.title = noteTitle || "";
note.isProtected = isProtected;
Expand All @@ -504,7 +503,7 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
title: noteTitle || "",
content: content,
noteId,
type,
type: type as NoteType,
mime,
prefix: noteMeta?.prefix || '',
isExpanded: !!noteMeta?.isExpanded,
Expand Down