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;
@@ -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 {
@@ -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)) {
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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.
+2
View File
@@ -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)}`);