Skip to content

Commit

Permalink
Merge pull request #8 from KarmaProd/master
Browse files Browse the repository at this point in the history
Fixing Issue #6 (Connection not closed)
  • Loading branch information
teastman authored Dec 23, 2021
2 parents aec2936 + bbe18b8 commit ecfb606
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ftp-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module.exports = function (RED) {
function FtpDownloadNode(n) {
RED.nodes.createNode(this, n);

const conn = new ftp();
const flow = this.context().flow;
const global = this.context().global;
const node = this;
Expand All @@ -60,7 +59,8 @@ module.exports = function (RED) {
let directory = "";

node.on('input', (msg) => {

const conn = new ftp();

// Load the files list from the appropriate variable.
try {
switch (node.filesType) {
Expand Down Expand Up @@ -121,6 +121,7 @@ module.exports = function (RED) {
promise
.then((filePaths)=> {
msg[node.output] = filePaths;
conn.end();
node.send(msg);
})
.catch((err) => {
Expand Down Expand Up @@ -185,7 +186,8 @@ module.exports = function (RED) {

node.on('close', () => {
try {
conn.destroy();
// conn.destroy();
// Line removed since connection should be already closed
}
catch (err) {
// Do nothing as the node is closed anyway.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-ftp-download",
"version": "1.0.4",
"version": "1.0.4.2",
"description": "A Node-RED node for FTP downloading.",
"dependencies": {
"ftp": "0.x"
Expand Down

0 comments on commit ecfb606

Please sign in to comment.