small style details

This commit is contained in:
Simon Martín 2018-06-22 10:50:39 +02:00
parent e7750eb4c8
commit 59dd495a87

View File

@ -71,14 +71,14 @@ function handleCopyTo (logger) {
res.header("Content-Disposition", `attachment; filename=${encodeURIComponent(filename)}`); res.header("Content-Disposition", `attachment; filename=${encodeURIComponent(filename)}`);
res.header("Content-Type", "application/octet-stream"); res.header("Content-Type", "application/octet-stream");
streamCopy.getPGStream(StreamCopy.ACTION_TO, function (err, pgstream) { streamCopy.getPGStream(StreamCopy.ACTION_TO, (err, pgstream) => {
if (err) { if (err) {
return next(err); return next(err);
} }
pgstream pgstream
.on('data', data => metrics.addSize(data.length)) .on('data', data => metrics.addSize(data.length))
.on('error', (err) => { .on('error', err => {
metrics.end(null, err); metrics.end(null, err);
pgstream.unpipe(res); pgstream.unpipe(res);
@ -94,8 +94,7 @@ function handleCopyTo (logger) {
.on('error', err => { .on('error', err => {
pgstream.emit('error', err); pgstream.emit('error', err);
}); });
} });
);
}; };
} }
@ -108,7 +107,7 @@ function handleCopyFrom (logger) {
const streamCopy = new StreamCopy(sql, userDbParams); const streamCopy = new StreamCopy(sql, userDbParams);
const metrics = new StreamCopyMetrics(logger, 'copyfrom', sql, user, isGzip); const metrics = new StreamCopyMetrics(logger, 'copyfrom', sql, user, isGzip);
streamCopy.getPGStream(StreamCopy.ACTION_FROM, function (err, pgstream) { streamCopy.getPGStream(StreamCopy.ACTION_FROM, (err, pgstream) => {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -127,7 +126,7 @@ function handleCopyFrom (logger) {
.pipe(isGzip ? zlib.createGunzip() : new PassThrough()) .pipe(isGzip ? zlib.createGunzip() : new PassThrough())
.on('data', data => metrics.addSize(data.length)) .on('data', data => metrics.addSize(data.length))
.pipe(pgstream) .pipe(pgstream)
.on('error', (err) => { .on('error', err => {
metrics.end(null, err); metrics.end(null, err);
req.unpipe(pgstream); req.unpipe(pgstream);
return next(err); return next(err);
@ -146,8 +145,7 @@ function handleCopyFrom (logger) {
total_rows: rows total_rows: rows
}); });
}); });
} });
);
}; };
} }