mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
fix(FTP Node): Fix issue with connections not closing properly (#8619)
This commit is contained in:
parent
a3bed97883
commit
e597fbc78f
|
@ -439,8 +439,8 @@ export class Ftp implements INodeType {
|
||||||
credential: ICredentialsDecrypted,
|
credential: ICredentialsDecrypted,
|
||||||
): Promise<INodeCredentialTestResult> {
|
): Promise<INodeCredentialTestResult> {
|
||||||
const credentials = credential.data as ICredentialDataDecryptedObject;
|
const credentials = credential.data as ICredentialDataDecryptedObject;
|
||||||
|
const ftp = new ftpClient();
|
||||||
try {
|
try {
|
||||||
const ftp = new ftpClient();
|
|
||||||
await ftp.connect({
|
await ftp.connect({
|
||||||
host: credentials.host as string,
|
host: credentials.host as string,
|
||||||
port: credentials.port as number,
|
port: credentials.port as number,
|
||||||
|
@ -448,11 +448,13 @@ export class Ftp implements INodeType {
|
||||||
password: credentials.password as string,
|
password: credentials.password as string,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
await ftp.end();
|
||||||
return {
|
return {
|
||||||
status: 'Error',
|
status: 'Error',
|
||||||
message: error.message,
|
message: error.message,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
await ftp.end();
|
||||||
return {
|
return {
|
||||||
status: 'OK',
|
status: 'OK',
|
||||||
message: 'Connection successful!',
|
message: 'Connection successful!',
|
||||||
|
@ -463,8 +465,8 @@ export class Ftp implements INodeType {
|
||||||
credential: ICredentialsDecrypted,
|
credential: ICredentialsDecrypted,
|
||||||
): Promise<INodeCredentialTestResult> {
|
): Promise<INodeCredentialTestResult> {
|
||||||
const credentials = credential.data as ICredentialDataDecryptedObject;
|
const credentials = credential.data as ICredentialDataDecryptedObject;
|
||||||
|
const sftp = new sftpClient();
|
||||||
try {
|
try {
|
||||||
const sftp = new sftpClient();
|
|
||||||
if (credentials.privateKey) {
|
if (credentials.privateKey) {
|
||||||
await sftp.connect({
|
await sftp.connect({
|
||||||
host: credentials.host as string,
|
host: credentials.host as string,
|
||||||
|
@ -483,11 +485,13 @@ export class Ftp implements INodeType {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
await sftp.end();
|
||||||
return {
|
return {
|
||||||
status: 'Error',
|
status: 'Error',
|
||||||
message: error.message,
|
message: error.message,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
await sftp.end();
|
||||||
return {
|
return {
|
||||||
status: 'OK',
|
status: 'OK',
|
||||||
message: 'Connection successful!',
|
message: 'Connection successful!',
|
||||||
|
@ -511,10 +515,9 @@ export class Ftp implements INodeType {
|
||||||
} else {
|
} else {
|
||||||
credentials = await this.getCredentials('ftp');
|
credentials = await this.getCredentials('ftp');
|
||||||
}
|
}
|
||||||
|
let ftp: ftpClient;
|
||||||
|
let sftp: sftpClient;
|
||||||
try {
|
try {
|
||||||
let ftp: ftpClient;
|
|
||||||
let sftp: sftpClient;
|
|
||||||
|
|
||||||
if (protocol === 'sftp') {
|
if (protocol === 'sftp') {
|
||||||
sftp = new sftpClient();
|
sftp = new sftpClient();
|
||||||
if (credentials.privateKey) {
|
if (credentials.privateKey) {
|
||||||
|
@ -809,6 +812,11 @@ export class Ftp implements INodeType {
|
||||||
await ftp!.end();
|
await ftp!.end();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (protocol === 'sftp') {
|
||||||
|
await sftp!.end();
|
||||||
|
} else {
|
||||||
|
await ftp!.end();
|
||||||
|
}
|
||||||
if (this.continueOnFail()) {
|
if (this.continueOnFail()) {
|
||||||
return [[{ json: { error: error.message } }]];
|
return [[{ json: { error: error.message } }]];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue