Skip to content

Commit

Permalink
feat: pipe stream on fs write (#206)
Browse files Browse the repository at this point in the history
* pipe allloewd on write stream

* code readable

* fix: 'if' statment missed curly braces

* Update src/commands/registration/stor.js

Replacing write data with pipe on STOR command

Co-authored-by: Tyler Stewart <[email protected]>

* fix: socket on data replaced with socket on pipe

* fix: extra space

Co-authored-by: Tyler Stewart <[email protected]>
Co-authored-by: Tyler Stewart <[email protected]>
  • Loading branch information
3 people authored Aug 25, 2020
1 parent 31290fc commit 05a68cf
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/commands/registration/stor.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ module.exports = {
});

const socketPromise = new Promise((resolve, reject) => {
this.connector.socket.on('data', (data) => {
if (this.connector.socket) this.connector.socket.pause();
if (stream && stream.writable) {
stream.write(data, () => this.connector.socket && this.connector.socket.resume());
}
});
this.connector.socket.pipe(stream, {end: false});
this.connector.socket.once('end', () => {
if (stream.listenerCount('close')) stream.emit('close');
else stream.end();
Expand Down

0 comments on commit 05a68cf

Please sign in to comment.