Create stream at the begining

This commit is contained in:
Daniel García Aubert 2019-05-16 15:06:27 +02:00
parent f7f96f004a
commit 62dc063677

View File

@ -113,6 +113,7 @@ function handleCopyFrom (logger) {
const streamCopy = new StreamCopy(sql, userDbParams, logger);
const metrics = new StreamCopyMetrics(logger, 'copyfrom', sql, user, isGzip);
const decompress = isGzip ? zlib.createGunzip() : new PassThrough();
streamCopy.getPGStream(StreamCopy.ACTION_FROM, (err, pgstream) => {
if (err) {
@ -136,6 +137,7 @@ function handleCopyFrom (logger) {
metrics.end(null, err);
pgstream.emit('error', err);
})
.pipe(decompress)
.on('data', data => {
metrics.addSize(data.length);