Add moveFileAndValidate

This commit is contained in:
HaveAGitGat 2023-08-29 12:13:23 +01:00
parent cf1b27c26d
commit d7c16474cf
7 changed files with 237 additions and 18 deletions

View file

@ -1,5 +1,6 @@
import { promises as fs } from 'fs';
import { getContainer, getFileName, getSubStem } from '../../../../FlowHelpers/1.0.0/fileUtils';
import {
getContainer, getFileName, getSubStem, moveFileAndValidate,
} from '../../../../FlowHelpers/1.0.0/fileUtils';
import {
IpluginDetails,
IpluginInputArgs,
@ -97,7 +98,13 @@ const plugin = async (args:IpluginInputArgs):Promise<IpluginOutputArgs> => {
args.jobLog(`Output path: ${ouputFilePath}`);
args.deps.fsextra.ensureDirSync(outputPath);
await fs.rename(args.inputFileObj._id, ouputFilePath);
await moveFileAndValidate({
inputPath: args.inputFileObj._id,
outputPath: ouputFilePath,
args,
});
return {
outputFileObj: {

View file

@ -1,3 +1,4 @@
import { moveFileAndValidate } from '../../../../FlowHelpers/1.0.0/fileUtils';
import {
IpluginDetails,
IpluginInputArgs,
@ -72,7 +73,11 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
fs.unlinkSync(newPath);
}
fs.renameSync(currentPath, newPathTmp);
await moveFileAndValidate({
inputPath: currentPath,
outputPath: newPathTmp,
args,
});
// delete original file
if (fs.existsSync(args.originalLibraryFile._id)) {
@ -80,7 +85,12 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
}
await new Promise((resolve) => setTimeout(resolve, 2000));
fs.renameSync(newPathTmp, newPath);
await moveFileAndValidate({
inputPath: newPathTmp,
outputPath: newPath,
args,
});
return {
outputFileObj: {