mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(FTP Node): Continue of fail looping support with paired item (#8659)
This commit is contained in:
parent
bee17dd6cc
commit
3279762221
|
@ -18,7 +18,7 @@ import type {
|
|||
INodeTypeDescription,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { formatPrivateKey } from '@utils/utilities';
|
||||
import { formatPrivateKey, generatePairedItemData } from '@utils/utilities';
|
||||
|
||||
interface ReturnFtpItem {
|
||||
type: string;
|
||||
|
@ -515,6 +515,8 @@ export class Ftp implements INodeType {
|
|||
}
|
||||
let ftp: ftpClient;
|
||||
let sftp: sftpClient;
|
||||
|
||||
try {
|
||||
try {
|
||||
if (protocol === 'sftp') {
|
||||
sftp = new sftpClient();
|
||||
|
@ -544,8 +546,17 @@ export class Ftp implements INodeType {
|
|||
password: credentials.password as string,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
const pairedItem = generatePairedItemData(items.length);
|
||||
|
||||
return [[{ json: { error: error.message }, pairedItem }]];
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
const newItem: INodeExecutionData = {
|
||||
json: items[i].json,
|
||||
binary: {},
|
||||
|
@ -658,7 +669,10 @@ export class Ftp implements INodeType {
|
|||
await sftp!.put(uploadData, remotePath);
|
||||
} else {
|
||||
// Is text file
|
||||
const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
||||
const buffer = Buffer.from(
|
||||
this.getNodeParameter('fileContent', i) as string,
|
||||
'utf8',
|
||||
);
|
||||
await sftp!.put(buffer, remotePath);
|
||||
}
|
||||
|
||||
|
@ -777,7 +791,10 @@ export class Ftp implements INodeType {
|
|||
}
|
||||
} else {
|
||||
// Is text file
|
||||
const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
|
||||
const buffer = Buffer.from(
|
||||
this.getNodeParameter('fileContent', i) as string,
|
||||
'utf8',
|
||||
);
|
||||
try {
|
||||
await ftp!.put(buffer, remotePath);
|
||||
} catch (error) {
|
||||
|
@ -797,6 +814,14 @@ export class Ftp implements INodeType {
|
|||
returnItems = returnItems.concat(executionData);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnItems.push({ json: { error: error.message }, pairedItem: { item: i } });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
if (protocol === 'sftp') {
|
||||
|
@ -810,10 +835,6 @@ export class Ftp implements INodeType {
|
|||
} else {
|
||||
await ftp!.end();
|
||||
}
|
||||
if (this.continueOnFail()) {
|
||||
return [[{ json: { error: error.message } }]];
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue