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

This commit is contained in:
PickleRick committed 2026-09-21 12:34:15 +02:00
1 parent a8c4a81141
commit 5d43ba6a26
8 files changed
+430 -20

No files matched your search

@@ -0,0 +1,70 @@
'use strict';
const path = require('path');
const fs = require('fs');
const { copyWithProgress } = require('../../../../FlowHelpers/1.0.0/copyWithProgress');
const details = () => ({
name: 'Copy Source to Work Dir (Progress)',
description:
'Copies the source file into the worker local workDir using a streamed, verified copy '
+ 'with progress updates. Use before transcode plugins for files on network shares.',
style: { borderColor: '#607D8B' },
tags: 'utility,copy,progress',
isStartPlugin: false,
pType: '',
requiresVersion: '2.11.01',
sidebarPosition: 0,
icon: 'faCopy',
inputs: [
{
label: 'Skip if already local',
name: 'skipIfLocal',
type: 'boolean',
defaultValue: 'true',
inputUI: { type: 'dropdown', options: ['true', 'false'] },
tooltip: 'Skip when the source is already inside workDir.',
},
],
outputs: [{ number: 1, tooltip: 'File is ready in workDir — continue to next plugin' }],
});
const plugin = async (args) => {
const { jobLog, inputFileObj, variables, workDir } = args;
const inputFile = inputFileObj._id;
const ext = path.extname(inputFile);
const baseName = path.basename(inputFile, ext);
const localCopy = path.join(workDir, `${baseName}_old${ext}`);
const skipIfLocal = (args.inputs.skipIfLocal || 'true') === 'true';
const relativeInput = path.relative(path.resolve(workDir), path.resolve(inputFile));
if (skipIfLocal && relativeInput !== '..' && !relativeInput.startsWith(`..${path.sep}`)
&& !path.isAbsolute(relativeInput)) {
jobLog('[copyToWorkDir] Source file is already inside workDir — skipping copy.\n');
return { outputNumber: 1, outputFileObj: inputFileObj, variables };
}
if (!fs.existsSync(inputFile)) throw new Error(`[copyToWorkDir] Source file not found: ${inputFile}`);
variables.originalLibraryFile = variables.originalLibraryFile || inputFile;
variables.originalLibraryDir = variables.originalLibraryDir || path.dirname(inputFile);
variables.workDirSourceBaseName = baseName;
variables.workDirCopyApplied = 'true';
jobLog(`[copyToWorkDir] Copying ${inputFile} to ${localCopy}\n`);
await copyWithProgress({
source: inputFile,
destination: localCopy,
jobLog,
updateProgress: args.updateProgress,
label: 'copyToWorkDir',
});
return {
outputNumber: 1,
outputFileObj: { ...inputFileObj, _id: localCopy },
variables,
};
};
module.exports.details = details;
module.exports.plugin = plugin;