A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: do not zip note without attachments on export
Abdullah Atta2b2cfe9d33b4
diff --git a/apps/web/src/common/export.ts b/apps/web/src/common/export.tsindex e750ca66a..890c825a1 100644--- a/apps/web/src/common/export.ts+++ b/apps/web/src/common/export.ts@@ -33,6 +33,9 @@ import Vault from "./vault";import { ExportStream } from "../utils/streams/export-stream";import { showToast } from "../utils/toast";import { ConfirmDialog } from "../dialogs/confirm";+import { db } from "./db";+import { toAsyncIterator } from "@notesnook-importer/core/dist/src/utils/stream";+import { saveAs } from "file-saver";export async function exportToPDF(title: string,@@ -151,21 +154,37 @@ export async function exportNote(title: `Exporting "${note.title}"`,subtitle: "Please wait while your note is exported.",action: async (report) => {- await fromAsyncIterator(+ const hasAttachments =+ (await db.relations.from(note, "attachment").count()) > 0;+ const stream = fromAsyncIterator(_exportNote(note, {format: options.format,unlockVault: Vault.unlockVault})- )- .pipeThrough(- new ExportStream(report, (e) => showToast("error", e.message))- )- .pipeThrough(createZipStream())- .pipeTo(- await createWriteStream(- `${sanitizeFilename(note.title, { replacement: "-" })}.zip`- )- );+ ).pipeThrough(+ new ExportStream(report, (e) => {+ console.error(e);+ showToast("error", e.message);+ })+ );++ if (hasAttachments) {+ await stream+ .pipeThrough(createZipStream())+ .pipeTo(+ await createWriteStream(+ `${sanitizeFilename(note.title, { replacement: "-" })}.zip`+ )+ );+ } else {+ for await (const file of toAsyncIterator(stream)) {+ if (typeof file.data === "string")+ saveAs(new Blob([Buffer.from(file.data, "utf-8")]), file.path);+ else if (file.data instanceof Uint8Array)+ saveAs(new Blob([file.data]), file.path);+ else await file.data.pipeTo(await createWriteStream(file.path));+ }+ }return true;}});