From 68166ad7eb883ed79328db78f8c164ccacb57edb Mon Sep 17 00:00:00 2001 From: PickleRick Date: Mon, 21 Sep 2026 22:49:46 +0200 Subject: [PATCH] Save uncommitted changes --- FlowHelpers/1.0.0/copyWithProgress.js | 10 ++++++++-- LocalFlowPlugins/utility/copyToWorkDir/2.0.0/index.js | 9 +++++++++ .../utility/replaceOriginalFile/2.0.0/index.js | 9 +++++++++ README.md | 3 ++- docs/integration-guide.md | 3 ++- tests/quick-logic-test.js | 2 ++ 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/FlowHelpers/1.0.0/copyWithProgress.js b/FlowHelpers/1.0.0/copyWithProgress.js index fd44026..74705a9 100644 --- a/FlowHelpers/1.0.0/copyWithProgress.js +++ b/FlowHelpers/1.0.0/copyWithProgress.js @@ -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; diff --git a/LocalFlowPlugins/utility/copyToWorkDir/2.0.0/index.js b/LocalFlowPlugins/utility/copyToWorkDir/2.0.0/index.js index f53a1c3..8929a99 100644 --- a/LocalFlowPlugins/utility/copyToWorkDir/2.0.0/index.js +++ b/LocalFlowPlugins/utility/copyToWorkDir/2.0.0/index.js @@ -33,6 +33,14 @@ const details = () => ({ inputUI: { type: 'dropdown', options: ['auto', 'native', 'stream'] }, tooltip: 'Auto uses the operating system copy API; stream is a fallback for problematic mounts.', }, + { + label: 'Stream buffer size (MB)', + name: 'bufferSizeMb', + type: 'string', + defaultValue: '16', + inputUI: { type: 'dropdown', options: ['4', '16', '64'] }, + tooltip: 'Used only with stream copy; larger values can improve high-latency SMB mounts.', + }, ], outputs: [{ number: 1, tooltip: 'File is ready in workDir — continue to next plugin' }], }); @@ -66,6 +74,7 @@ const plugin = async (args) => { updateProgress: args.updateProgress, label: 'copyToWorkDir', copyMethod: args.inputs.copyMethod || 'auto', + bufferSizeMb: args.inputs.bufferSizeMb || '16', }); return { diff --git a/LocalFlowPlugins/utility/replaceOriginalFile/2.0.0/index.js b/LocalFlowPlugins/utility/replaceOriginalFile/2.0.0/index.js index 0b4602e..4cd9ba9 100644 --- a/LocalFlowPlugins/utility/replaceOriginalFile/2.0.0/index.js +++ b/LocalFlowPlugins/utility/replaceOriginalFile/2.0.0/index.js @@ -33,6 +33,14 @@ const details = () => ({ inputUI: { type: 'dropdown', options: ['auto', 'native', 'stream'] }, tooltip: 'Auto uses the operating system copy API; stream is a fallback for problematic mounts.', }, + { + label: 'Stream buffer size (MB)', + name: 'bufferSizeMb', + type: 'string', + defaultValue: '16', + inputUI: { type: 'dropdown', options: ['4', '16', '64'] }, + tooltip: 'Used only with stream copy; larger values can improve high-latency SMB mounts.', + }, ], outputs: [{ number: 1, tooltip: 'Original file replaced — continue to next plugin' }], }); @@ -71,6 +79,7 @@ const plugin = async (args) => { updateProgress: args.updateProgress, label: 'replaceOriginalFile', copyMethod: args.inputs.copyMethod || 'auto', + bufferSizeMb: args.inputs.bufferSizeMb || '16', }); if (fs.existsSync(destination)) { diff --git a/README.md b/README.md index f243846..2d2217b 100644 --- a/README.md +++ b/README.md @@ -281,7 +281,8 @@ Streams the source file to the worker's local `workDir`, verifies the byte count reports throttled copy progress, and retries failed writes twice after removing the partial destination. Its `Copy method` input defaults to `auto` (the operating system's native file-copy path) and offers `stream` as a fallback -for problematic mounts. It stores the original library path in +for problematic mounts. The stream fallback defaults to a 16 MB buffer and +offers 4 MB or 64 MB alternatives. It stores the original library path in `variables.originalLibraryFile` for `replaceOriginalFile`. ### 9. `replaceOriginalFile` — Replace Original File diff --git a/docs/integration-guide.md b/docs/integration-guide.md index 14525ac..3323fbe 100644 --- a/docs/integration-guide.md +++ b/docs/integration-guide.md @@ -124,7 +124,8 @@ the library path for `replaceOriginalFile` 2.0.0. Both progress-enabled copy operations verify the destination size and retry failed writes twice after removing the partial destination. Their `Copy method` input defaults to `auto` (the operating system's native file-copy path), with -`stream` available as a fallback for problematic SMB/CIFS mounts. +`stream` available as a fallback for problematic SMB/CIFS mounts. Stream mode +supports 4 MB, 16 MB, and 64 MB buffers. Both progress-enabled plugins require `FlowHelpers/1.0.0/copyWithProgress.js`; the installer downloads it automatically. diff --git a/tests/quick-logic-test.js b/tests/quick-logic-test.js index ad3c4bb..05a3071 100644 --- a/tests/quick-logic-test.js +++ b/tests/quick-logic-test.js @@ -225,6 +225,8 @@ const AUDIO_INPUTS = { ok(copyHelperCode.includes('fs.promises.copyFile(source, destination)'), 'copy helper uses native file copying'); ok(copyHelperCode.includes("copyMethod = 'auto'"), 'copy helper defaults to automatic copy selection'); ok(copyHelperCode.includes("copyMethod === 'stream'"), 'copy helper supports stream fallback'); + ok(copyHelperCode.includes('bufferSizeMb = 16'), 'copy helper defaults stream buffer to 16 MB'); + ok(copyHelperCode.includes('128'), 'copy helper caps stream buffer size'); // ── Summary ─────────────────────────────────────────────────────────────── console.log(`\n${'='.repeat(55)}`);