Harden Mega web flow and smooth download runtime
Build and Release / build (push) Has been cancelled

This commit is contained in:
Sucukdeluxe
2026-02-27 06:17:15 +01:00
parent 40bfda2ad7
commit 583d74fcc9
9 changed files with 198 additions and 61 deletions
+3 -2
View File
@@ -83,8 +83,9 @@ async function hashFile(filePath: string, algorithm: "crc32" | "md5" | "sha1"):
const stream = fs.createReadStream(filePath, { highWaterMark: 1024 * 1024 });
return await new Promise<string>((resolve, reject) => {
let crc = 0;
stream.on("data", (chunk: Buffer) => {
crc = crc32Buffer(chunk, crc);
stream.on("data", (chunk: string | Buffer) => {
const buffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
crc = crc32Buffer(buffer, crc);
});
stream.on("error", reject);
stream.on("end", () => resolve(((crc >>> 0).toString(16)).padStart(8, "0").toLowerCase()));