From 3ede1ea9f1842a6deb45197dacd78c6a857a2e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Thu, 21 Jun 2018 14:53:07 +0200 Subject: [PATCH] unify streams --- app/services/stream_copy.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/app/services/stream_copy.js b/app/services/stream_copy.js index 821cc8fc..243f7ca5 100644 --- a/app/services/stream_copy.js +++ b/app/services/stream_copy.js @@ -12,8 +12,7 @@ module.exports = class StreamCopy { this.sql = sql; this.connectionClosedByClient = false; - this.copyToStream = null; - this.copyFromStream = null; + this.stream = null; } static get ACTION_TO() { @@ -30,8 +29,8 @@ module.exports = class StreamCopy { return cb(err); } - this.copyToStream = copyTo(this.sql); - const pgstream = client.query(this.copyToStream); + this.stream = copyTo(this.sql); + const pgstream = client.query(this.stream); pgstream .on('end', () => done()) @@ -55,8 +54,8 @@ module.exports = class StreamCopy { return cb(err); } - this.copyFromStream = copyFrom(this.sql); - const pgstream = client.query(this.copyFromStream); + this.stream = copyFrom(this.sql); + const pgstream = client.query(this.stream); pgstream .on('end', () => done()) @@ -69,13 +68,7 @@ module.exports = class StreamCopy { }); } - getRowCount(action = ACTION_TO) { - if (action === ACTION_TO && this.copyToStream) { - return this.copyToStream.rowCount; - } - - if (action === ACTION_FROM && this.copyFromStream) { - return this.copyFromStream.rowCount; - } + getRowCount() { + return this.stream.rowCount; } };