diff --git a/src/commands/index.js b/src/commands/index.js index a0cd02a0..8d8f56e0 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -68,7 +68,7 @@ class FtpCommands { const handler = commandRegister.handler.bind(this.connection); return Promise.resolve(handler({log, command, previous_command: this.previousCommand})) - .finally(() => { + .then(() => { this.previousCommand = _.clone(command); }); } diff --git a/src/commands/registration/abor.js b/src/commands/registration/abor.js index 1759b011..5d134c36 100644 --- a/src/commands/registration/abor.js +++ b/src/commands/registration/abor.js @@ -7,7 +7,7 @@ module.exports = { .then(() => this.reply(226)); }) .catch(() => this.reply(225)) - .finally(() => this.connector.end()); + .then(() => this.connector.end()); }, syntax: '{{cmd}}', description: 'Abort an active file transfer' diff --git a/src/commands/registration/list.js b/src/commands/registration/list.js index 3e258cbe..dd6c6605 100644 --- a/src/commands/registration/list.js +++ b/src/commands/registration/list.js @@ -47,7 +47,7 @@ module.exports = { log.error(err); return this.reply(451, err.message || 'No directory'); }) - .finally(() => { + .then(() => { this.connector.end(); this.commandSocket.resume(); }); diff --git a/src/commands/registration/retr.js b/src/commands/registration/retr.js index de906359..2a5e1075 100644 --- a/src/commands/registration/retr.js +++ b/src/commands/registration/retr.js @@ -43,7 +43,7 @@ module.exports = { .then(() => eventsPromise) .tap(() => this.emit('RETR', null, serverPath)) .then(() => this.reply(226, clientPath)) - .finally(() => stream.destroy && stream.destroy()); + .then(() => stream.destroy && stream.destroy()); }) .catch(Promise.TimeoutError, (err) => { log.error(err); @@ -54,7 +54,7 @@ module.exports = { this.emit('RETR', err); return this.reply(551, err.message); }) - .finally(() => { + .then(() => { this.connector.end(); this.commandSocket.resume(); }); diff --git a/src/commands/registration/rnto.js b/src/commands/registration/rnto.js index 7fe33167..d6dbb73a 100644 --- a/src/commands/registration/rnto.js +++ b/src/commands/registration/rnto.js @@ -21,7 +21,7 @@ module.exports = { this.emit('RNTO', err); return this.reply(550, err.message); }) - .finally(() => { + .then(() => { delete this.renameFrom; }); }, diff --git a/src/commands/registration/stor.js b/src/commands/registration/stor.js index ed6a7adb..a07f3ed0 100644 --- a/src/commands/registration/stor.js +++ b/src/commands/registration/stor.js @@ -52,7 +52,7 @@ module.exports = { .then(() => Promise.all([streamPromise, socketPromise])) .tap(() => this.emit('STOR', null, serverPath)) .then(() => this.reply(226, clientPath)) - .finally(() => stream.destroy && stream.destroy()); + .then(() => stream.destroy && stream.destroy()); }) .catch(Promise.TimeoutError, (err) => { log.error(err); @@ -63,7 +63,7 @@ module.exports = { this.emit('STOR', err); return this.reply(550, err.message); }) - .finally(() => { + .then(() => { this.connector.end(); this.commandSocket.resume(); }); diff --git a/src/connection.js b/src/connection.js index fc965038..8389dcba 100644 --- a/src/connection.js +++ b/src/connection.js @@ -72,7 +72,7 @@ class FtpConnection extends EventEmitter { close(code = 421, message = 'Closing connection') { return Promise.resolve(code) .then((_code) => _code && this.reply(_code, message)) - .finally(() => this.commandSocket && this.commandSocket.destroy()); + .then(() => this.commandSocket && this.commandSocket.destroy()); } login(username, password) { diff --git a/src/connector/passive.js b/src/connector/passive.js index b9705c49..d3c2c045 100644 --- a/src/connector/passive.js +++ b/src/connector/passive.js @@ -44,7 +44,7 @@ class Passive extends Connector { socket.destroy(); return this.connection.reply(550, 'Remote addresses do not match') - .finally(() => this.connection.close()); + .then(() => this.connection.close()); } clearTimeout(idleServerTimeout); diff --git a/src/index.js b/src/index.js index d79d5565..859540df 100644 --- a/src/index.js +++ b/src/index.js @@ -58,7 +58,7 @@ class FtpServer extends EventEmitter { const greeting = this._greeting || []; const features = this._features || 'Ready'; return connection.reply(220, ...greeting, features) - .finally(() => socket.resume()); + .then(() => socket.resume()); }; const serverOptions = Object.assign({}, this.isTLS ? this.options.tls : {}, {pauseOnConnect: true}); @@ -145,7 +145,7 @@ class FtpServer extends EventEmitter { quit() { return this.close() - .finally(() => process.exit(0)); + .then(() => process.exit(0)); } close() { diff --git a/test/connector/active.spec.js b/test/connector/active.spec.js index dc36b2f3..139d1b8a 100644 --- a/test/connector/active.spec.js +++ b/test/connector/active.spec.js @@ -54,7 +54,7 @@ describe('Connector - Active //', function () { expect(err.code).to.equal(500); expect(err.message).to.equal('The given address is not yours'); }) - .finally(() => { + .then(() => { expect(active.dataSocket).not.to.exist; }); });