progress indicator in exports

This commit is contained in:
SPRINX0\prochazka
2025-03-04 13:55:36 +01:00
parent 4006f03444
commit 0c104d5d29
8 changed files with 87 additions and 12 deletions

View File

@@ -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];

View File

@@ -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;
}
}