My hierarchy looks something like this
1st level: Folder 1 (Phoenix) Can't delete
2nd level: Folder 2 (modelName) Can't delete
3rd level: Folder 3 and Folder 4 ( PDF sizes and reports) Can delete these
Tried using 3 different functions, but the same problem still exists.
I Can delete the files with Node.
When trying to save to desktop, windows says the folder is no longer located ther, although it most certainly is.
Code: Select all
const fs = require('fs-extra');
async function jobArrived(s, flowElement, job) {
try {
let tempPath = await job.get(AccessLevel.ReadWrite); //file path
//data from switch for functions
let originalPath = await flowElement.getPropertyStringValue("OriginPath");
// new location for creating extra folders
let modelName = await flowElement.getPropertyStringValue("GetModelFolder");
//folder name for creating folder modelName
let fileName = await flowElement.getPropertyStringValue("GetFileName");
//file name
//create directories for files Phoenix folder + PDF sizes + Reports folder
async function CreateFLDRS (directory) {
try {
await fs.ensureDir(directory)
await job.log(LogLevel.Info, "Folders created");
} catch (err) {
await job.log(LogLevel.Error, err.message);
}
};
await CreateFLDRS(originalPath + "/Phoenix" +"/" + modelName + "/PDF sizes");
await CreateFLDRS(originalPath + "/Phoenix" +"/" + modelName + "/Reports");
//move files to correct folder
let PDFloc = originalPath + "/Phoenix" +"/" + modelName + "/Reports" + "/" + fileName
async function MoveFile () {
try {
await fs.copy(tempPath,PDFloc)
} catch (err) {
await job.log(LogLevel.Error, err.message);
}
};
await MoveFile();
await job.sendToSingle();
}
catch(e) {
await job.log(LogLevel.Error, e.message);
}
};