파일을 업로드할 때, 파일의 내용이 아닌 해시가 서버의 파일 시스템에 기록되던 버그 수정

This commit is contained in:
static
2025-01-18 18:54:49 +09:00
parent 10eba78444
commit 53bc426487

View File

@@ -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) {