diff --git a/src/updater/moduleUpdater.js b/src/updater/moduleUpdater.js index 977e6a9..60f1c83 100644 --- a/src/updater/moduleUpdater.js +++ b/src/updater/moduleUpdater.js @@ -67,7 +67,9 @@ exports.init = (endpoint, { releaseChannel, version }) => { }); events.emit('downloading-module', { - name: 'host' + name: 'host', + current: 1, + total: 1 }); }); @@ -93,11 +95,15 @@ exports.init = (endpoint, { releaseChannel, version }) => { checking = false; events.emit('downloaded-module', { - name: 'host' + name: 'host', + current: 1, + total: 1, + succeeded: true }); events.emit('downloading-modules-finished', { - succeeded: 1 + succeeded: 1, + failed: 0 }); }); @@ -176,7 +182,9 @@ const checkModules = async () => { const downloadModule = async (name, ver) => { downloading.total++; events.emit('downloading-module', { - name + name, + current: downloading.total, + total: downloading.total }); const url = baseUrl + '/' + name + '/' + ver; @@ -186,6 +194,7 @@ const downloadModule = async (name, ver) => { stream.on('progress', ([ cur, total ]) => events.emit('downloading-module-progress', { name, + progress: Math.min(100, Math.floor(100 * (cur / total))), cur, total })); @@ -211,7 +220,9 @@ const downloadModule = async (name, ver) => { else downloading.fail++; events.emit('downloaded-module', { - name + name, + current: downloading.total, + total: downloading.total }); @@ -233,7 +244,9 @@ const downloadModule = async (name, ver) => { const installModule = async (name, ver, path) => { installing.total++; events.emit('installing-module', { - name + name, + current: installing.total, + total: installing.total }); log('Modules', 'Installing', `${name}@${ver}`, 'from', path); @@ -286,6 +299,7 @@ const installModule = async (name, ver, path) => { cur++; events.emit('installing-module-progress', { name, + progress: Math.min(100, Math.floor(cur / total * 100)), cur, total }); @@ -305,7 +319,10 @@ const finishInstall = (name, ver, success) => { if (!success) installing.fail++; events.emit('installed-module', { - name + name, + current: installing.total, + total: installing.total, + succeeded: success }); installing.done++;