Skip to content

Build your personal knowledge base with Trilium Notes

server: Fix import of notes with type=file

Elian Dorand99cc11d8bfc
diff --git a/src/becca/entities/rows.ts b/src/becca/entities/rows.ts
index 4258c3805c..119d392ec3 100644
--- a/src/becca/entities/rows.ts
+++ b/src/becca/entities/rows.ts
@@ -107,5 +107,5 @@ export interface NoteRow {
dateModified: string;
utcDateCreated: string;
utcDateModified: string;
- content?: string;
+ content?: string | Buffer;
}
diff --git a/src/services/import/zip.ts b/src/services/import/zip.ts
index 203b36442e..f8391350b9 100644
--- a/src/services/import/zip.ts
+++ b/src/services/import/zip.ts
@@ -500,10 +500,6 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
}
}
else {
- if (typeof content !== "string") {
- throw new Error("Incorrect content type.");
- }
-
({note} = noteService.createNewNote({
parentNoteId: parentNoteId,
title: noteTitle || "",
diff --git a/src/services/note-interface.ts b/src/services/note-interface.ts
index 0b99c31ef3..2cfa0b86ac 100644
--- a/src/services/note-interface.ts
+++ b/src/services/note-interface.ts
@@ -7,7 +7,7 @@ export interface NoteParams {
parentNoteId: string;
templateNoteId?: string;
title: string;
- content: string;
+ content: string | Buffer;
/** text, code, file, image, search, book, relationMap, canvas, webView */
type: NoteType;
/** default value is derived from default mimes for type */
diff --git a/src/services/search/expressions/note_content_fulltext.ts b/src/services/search/expressions/note_content_fulltext.ts
index ada9705a27..02626bf161 100644
--- a/src/services/search/expressions/note_content_fulltext.ts
+++ b/src/services/search/expressions/note_content_fulltext.ts
@@ -74,7 +74,7 @@ class NoteContentFulltextExp extends Expression {
}
if (isProtected) {
- if (!protectedSessionService.isProtectedSessionAvailable() || !content) {
+ if (!protectedSessionService.isProtectedSessionAvailable() || !content || typeof content !== "string") {
return;
}
@@ -86,7 +86,7 @@ class NoteContentFulltextExp extends Expression {
}
}
- if (!content) {
+ if (!content || typeof content !== "string") {
return;
}