Skip to content

Commit

Permalink
fix: replace .finally with .then (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
almgwary authored Jun 24, 2022
1 parent 4ba5834 commit a8cdcb0
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/registration/abor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/registration/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
4 changes: 2 additions & 2 deletions src/commands/registration/retr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -54,7 +54,7 @@ module.exports = {
this.emit('RETR', err);
return this.reply(551, err.message);
})
.finally(() => {
.then(() => {
this.connector.end();
this.commandSocket.resume();
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/registration/rnto.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
this.emit('RNTO', err);
return this.reply(550, err.message);
})
.finally(() => {
.then(() => {
delete this.renameFrom;
});
},
Expand Down
4 changes: 2 additions & 2 deletions src/commands/registration/stor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -63,7 +63,7 @@ module.exports = {
this.emit('STOR', err);
return this.reply(550, err.message);
})
.finally(() => {
.then(() => {
this.connector.end();
this.commandSocket.resume();
});
Expand Down
2 changes: 1 addition & 1 deletion src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/connector/passive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down Expand Up @@ -145,7 +145,7 @@ class FtpServer extends EventEmitter {

quit() {
return this.close()
.finally(() => process.exit(0));
.then(() => process.exit(0));
}

close() {
Expand Down
2 changes: 1 addition & 1 deletion test/connector/active.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
Expand Down

0 comments on commit a8cdcb0

Please sign in to comment.