fix(FTP Node): Fix issue with creating folders on rename (#9340)

This commit is contained in:
Jon 2024-12-10 14:33:09 +00:00 committed by GitHub
parent 2d36b42798
commit eb7d5934ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -752,10 +752,20 @@ export class Ftp implements INodeType {
if (operation === 'rename') { if (operation === 'rename') {
const oldPath = this.getNodeParameter('oldPath', i) as string; const oldPath = this.getNodeParameter('oldPath', i) as string;
const newPath = this.getNodeParameter('newPath', i) as string; const newPath = this.getNodeParameter('newPath', i) as string;
const options = this.getNodeParameter('options', i);
try {
await ftp!.rename(oldPath, newPath); await ftp!.rename(oldPath, newPath);
} catch (error) {
if ([451, 550].includes(error.code) && options.createDirectories) {
const dirPath = newPath.replace(basename(newPath), '');
await ftp!.mkdir(dirPath, true);
await ftp!.rename(oldPath, newPath);
} else {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
const executionData = this.helpers.constructExecutionMetaData( const executionData = this.helpers.constructExecutionMetaData(
[{ json: { success: true } }], [{ json: { success: true } }],
{ itemData: { item: i } }, { itemData: { item: i } },