fix: replace .finally with .then (#322)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ module.exports = {
|
||||
this.emit('RNTO', err);
|
||||
return this.reply(550, err.message);
|
||||
})
|
||||
.finally(() => {
|
||||
.then(() => {
|
||||
delete this.renameFrom;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user