mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(FTP Node): Fix issue with creating folders on rename (#9340)
This commit is contained in:
parent
2d36b42798
commit
eb7d5934ef
|
@ -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);
|
||||||
|
|
||||||
await ftp!.rename(oldPath, newPath);
|
try {
|
||||||
|
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 } },
|
||||||
|
|
Loading…
Reference in a new issue