From 53bc4264876227bc49945bdb17c72c3c50e5b29e Mon Sep 17 00:00:00 2001 From: static Date: Sat, 18 Jan 2025 18:54:49 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EC=9D=84=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=ED=95=A0=20=EB=95=8C,=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EC=9D=98=20=EB=82=B4=EC=9A=A9=EC=9D=B4=20=EC=95=84=EB=8B=8C=20?= =?UTF-8?q?=ED=95=B4=EC=8B=9C=EA=B0=80=20=EC=84=9C=EB=B2=84=EC=9D=98=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=8B=9C=EC=8A=A4=ED=85=9C=EC=97=90=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D=EB=90=98=EB=8D=98=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/server/services/file.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/server/services/file.ts b/src/lib/server/services/file.ts index cabcc1d..ea01f16 100644 --- a/src/lib/server/services/file.ts +++ b/src/lib/server/services/file.ts @@ -112,7 +112,16 @@ export const uploadFile = async ( try { const hashStream = createHash("sha256"); const [_, hash] = await Promise.all([ - pipeline(encContentStream, hashStream, createWriteStream(path, { flags: "wx", mode: 0o600 })), + pipeline( + encContentStream, + async function* (source) { + for await (const chunk of source) { + hashStream.update(chunk); + yield chunk; + } + }, + createWriteStream(path, { flags: "wx", mode: 0o600 }), + ), encContentHash, ]); if (hashStream.digest("base64") != hash) {