diff --git a/apps/server/src/services/export/zip.ts b/apps/server/src/services/export/zip.ts index a0c32ef6bd..e9eec69bf5 100644 --- a/apps/server/src/services/export/zip.ts +++ b/apps/server/src/services/export/zip.ts @@ -343,7 +343,9 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch, content = prepareContent(noteMeta.title, content, noteMeta, undefined); - archive.append(content as Buffer, { name: filePathPrefix + noteMeta.dataFileName }); + archive.append(typeof content === "string" ? content : Buffer.from(content), { + name: filePathPrefix + noteMeta.dataFileName + }); return; } @@ -375,7 +377,7 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch, const attachment = note.getAttachmentById(attachmentMeta.attachmentId); const content = attachment.getContent(); - archive.append(content as Buffer, { + archive.append(typeof content === "string" ? content : Buffer.from(content), { name: filePathPrefix + attachmentMeta.dataFileName, date: dateUtils.parseDateTime(note.utcDateModified) }); diff --git a/apps/server/src/services/export/zip/share_theme.ts b/apps/server/src/services/export/zip/share_theme.ts index 534ccf785b..79fff7606e 100644 --- a/apps/server/src/services/export/zip/share_theme.ts +++ b/apps/server/src/services/export/zip/share_theme.ts @@ -149,8 +149,8 @@ export default class ShareThemeExportProvider extends ZipExportProvider { } const note = this.branch.getNote(); - const fullHtml = this.prepareContent(rootMeta.title ?? "", note.getContent(), rootMeta, note, this.branch); - this.archive.append(fullHtml as Buffer, { name: this.indexMeta.dataFileName }); + const content = this.prepareContent(rootMeta.title ?? "", note.getContent(), rootMeta, note, this.branch); + this.archive.append(typeof content === "string" ? content : Buffer.from(content), { name: this.indexMeta.dataFileName }); } #saveAssets(rootMeta: NoteMeta, assetsMeta: NoteMeta[]) { @@ -178,7 +178,9 @@ export default class ShareThemeExportProvider extends ZipExportProvider { continue; }; const fontFileName = `assets/icon-pack-${iconPack.prefix.toLowerCase()}.${extension}`; - this.archive.append(fontData as Buffer, { name: fontFileName }); + this.archive.append(typeof fontData === "string" ? fontData : Buffer.from(fontData), { + name: fontFileName + }); } } diff --git a/packages/trilium-core/src/services/blob.ts b/packages/trilium-core/src/services/blob.ts index 6792c75270..09e72ee951 100644 --- a/packages/trilium-core/src/services/blob.ts +++ b/packages/trilium-core/src/services/blob.ts @@ -39,8 +39,7 @@ function processContent(content: Uint8Array | string | null, isProtected: boolea if (isStringContent) { if (content === null) return ""; - if (typeof content === "string") return content; - return decodeUtf8(content as Uint8Array); + return decodeUtf8(content); } // see https://github.com/zadam/trilium/issues/3523 // IIRC a zero-sized buffer can be returned as null from the database diff --git a/packages/trilium-core/src/services/events.ts b/packages/trilium-core/src/services/events.ts index dcdc5793c4..f37eef1d6e 100644 --- a/packages/trilium-core/src/services/events.ts +++ b/packages/trilium-core/src/services/events.ts @@ -1,4 +1,4 @@ -import log, { getLog } from "./log.js"; +import { getLog } from "./log.js"; const NOTE_TITLE_CHANGED = "NOTE_TITLE_CHANGED"; const ENTER_PROTECTED_SESSION = "ENTER_PROTECTED_SESSION";