fix: replace .finally with .then (#322)

This commit is contained in:
Amr Ibrahim
2022-06-24 18:55:10 +02:00
committed by GitHub
parent 4ba583420a
commit a8cdcb0eb3
10 changed files with 13 additions and 13 deletions

View File

@@ -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);
});
}

View File

@@ -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'

View File

@@ -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();
});

View File

@@ -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();
});

View File

@@ -21,7 +21,7 @@ module.exports = {
this.emit('RNTO', err);
return this.reply(550, err.message);
})
.finally(() => {
.then(() => {
delete this.renameFrom;
});
},

View File

@@ -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();
});

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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;
});
});