Save uncommitted changes
Build / Lint & Test (push) Successful in 36s

This commit is contained in:
PickleRick committed 2026-09-21 22:49:46 +02:00
1 parent 594889ea10
commit 68166ad7eb
6 files changed
+32 -4

No files matched your search

+8 -2
View File
@@ -9,11 +9,17 @@ const copyWithProgress = async ({
updateProgress,
label,
copyMethod = 'auto',
bufferSizeMb = 16,
maxRetries = 2,
retryDelayMs = 1000,
}) => {
const sourceSize = fs.statSync(source).size;
const sourceSizeMb = (sourceSize / 1024 / 1024).toFixed(1);
const normalizedBufferSizeMb = Math.min(
Math.max(Number.parseInt(bufferSizeMb, 10) || 16, 1),
128,
);
const bufferSize = normalizedBufferSizeMb * 1024 * 1024;
const report = (percent, message) => {
const boundedPercent = Math.min(Math.max(percent, 0), 100);
@@ -30,8 +36,8 @@ const copyWithProgress = async ({
const startMs = Date.now();
let copiedBytes = 0;
let nextProgressPercent = 0;
const rd = fs.createReadStream(source, { highWaterMark: 4 * 1024 * 1024 });
const wr = fs.createWriteStream(destination, { highWaterMark: 4 * 1024 * 1024 });
const rd = fs.createReadStream(source, { highWaterMark: bufferSize });
const wr = fs.createWriteStream(destination, { highWaterMark: bufferSize });
let settled = false;
const fail = (error) => {
if (settled) return;