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: fix `pull failed` error on downloading attachments
Abdullah Atta433e67a6dc5a
diff --git a/apps/web/__tests__/chunked-stream.test.ts b/apps/web/__tests__/chunked-stream.test.tsindex c2dcf10bf..22ea756eb 100644--- a/apps/web/__tests__/chunked-stream.test.ts+++ b/apps/web/__tests__/chunked-stream.test.ts@@ -26,20 +26,25 @@ import { consumeReadableStream } from "../src/utils/stream";import { xxhash64 } from "hash-wasm";import path from "path";-const CHUNK_SIZE = 512 * 1024;+const CHUNK_SIZE = 512 * 1024 + 17;test("chunked stream should create equal sized chunks", async (t) => {const chunks = await consumeReadableStream((Readable.toWeb(- createReadStream(- path.join(__dirname, "..", "__e2e__", "data", "importer-data.zip")- )+ createReadStream(path.join(__dirname, "data", "35a4b0a78dbb9260"))) as ReadableStream<Uint8Array>- ).pipeThrough(new ChunkedStream(CHUNK_SIZE))+ ).pipeThrough(new ChunkedStream(CHUNK_SIZE, "copy")));t.expect(await Promise.all(chunks.map((a) => xxhash64(a)))).toMatchObject([- "6234b76401d9eb97",- "338834da3f6500b2"+ "9a3fa91d341b245d",+ "c6b5d3ec17f14a5e",+ "5163243faf462ce4",+ "63aca6b8a7f68476",+ "cd9d082fa3015bd3"]);++ t.expect(+ await Promise.all(chunks.map((a) => a.byteOffset === 0))+ ).toMatchObject([true, true, true, true, true]);});diff --git a/apps/web/__tests__/data/35a4b0a78dbb9260 b/apps/web/__tests__/data/35a4b0a78dbb9260new file mode 100644index 000000000..84037b201Binary files /dev/null and b/apps/web/__tests__/data/35a4b0a78dbb9260 differdiff --git a/apps/web/src/utils/streams/chunked-stream.ts b/apps/web/src/utils/streams/chunked-stream.tsindex cb6b1388e..8204def30 100644--- a/apps/web/src/utils/streams/chunked-stream.ts+++ b/apps/web/src/utils/streams/chunked-stream.ts@@ -55,7 +55,11 @@ export class ChunkedStream extends TransformStream<Uint8Array, Uint8Array> {}},flush(controller) {- if (backBuffer) controller.enqueue(backBuffer);+ if (backBuffer) {+ const buffer =+ mode === "copy" ? new Uint8Array(backBuffer) : backBuffer;+ controller.enqueue(buffer);+ }}});}