Skip to content

Commit 6020409

Browse files
committed
feat(retr): emit connection event on success/failure
1 parent c606069 commit 6020409

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/commands/registration/retr.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ module.exports = {
66
if (!this.fs) return this.reply(550, 'File system not instantiated');
77
if (!this.fs.read) return this.reply(402, 'Not supported by file system');
88

9+
const filePath = command.arg;
10+
911
return this.connector.waitForConnection()
1012
.tap(() => this.commandSocket.pause())
11-
.then(() => Promise.resolve(this.fs.read(command.arg, {start: this.restByteCount})))
13+
.then(() => Promise.resolve(this.fs.read(filePath, {start: this.restByteCount})))
1214
.then(stream => {
1315
const destroyConnection = (connection, reject) => err => {
1416
if (connection) connection.destroy(err);
@@ -32,6 +34,7 @@ module.exports = {
3234

3335
return this.reply(150).then(() => stream.resume() && this.connector.socket.resume())
3436
.then(() => eventsPromise)
37+
.tap(() => this.emit('RETR', null, filePath))
3538
.finally(() => stream.destroy && stream.destroy());
3639
})
3740
.then(() => this.reply(226))
@@ -41,6 +44,7 @@ module.exports = {
4144
})
4245
.catch(err => {
4346
log.error(err);
47+
this.emit('RETR', err);
4448
return this.reply(551, err.message);
4549
})
4650
.finally(() => {

0 commit comments

Comments
 (0)