mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 19:36:00 +00:00
progress indicator in exports
This commit is contained in:
@@ -107,6 +107,10 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
handle_progress(runid, { progressName, status }) {
|
||||
socket.emit(`runner-progress-${runid}`, { progressName, status });
|
||||
},
|
||||
|
||||
rejectRequest(runid, error) {
|
||||
if (this.requests[runid]) {
|
||||
const { reject } = this.requests[runid];
|
||||
|
||||
@@ -10,7 +10,15 @@ const streamPipeline = require('../utility/streamPipeline');
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function copyStream(input, output, options) {
|
||||
const { columns } = options || {};
|
||||
const { columns, progressName } = options || {};
|
||||
|
||||
if (progressName) {
|
||||
process.send({
|
||||
msgtype: 'progress',
|
||||
progressName,
|
||||
status: 'running',
|
||||
});
|
||||
}
|
||||
|
||||
const transforms = [];
|
||||
if (columns) {
|
||||
@@ -22,6 +30,14 @@ async function copyStream(input, output, options) {
|
||||
|
||||
try {
|
||||
await streamPipeline(input, transforms, output);
|
||||
|
||||
if (progressName) {
|
||||
process.send({
|
||||
msgtype: 'progress',
|
||||
progressName,
|
||||
status: 'done',
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
process.send({
|
||||
msgtype: 'copyStreamError',
|
||||
@@ -30,6 +46,15 @@ async function copyStream(input, output, options) {
|
||||
...err,
|
||||
},
|
||||
});
|
||||
|
||||
if (progressName) {
|
||||
process.send({
|
||||
msgtype: 'progress',
|
||||
progressName,
|
||||
status: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user