[Updater > Module] More renaming of some general events
This commit is contained in:
parent
25ff7efdc0
commit
e4990cd3ad
2 changed files with 24 additions and 31 deletions
|
@ -184,24 +184,26 @@ const initOld = () => { // "Old" (not v2 / new, win32 only)
|
|||
fail(check);
|
||||
};
|
||||
|
||||
on('update-check-finished', ({ succeeded, updateCount }) => {
|
||||
on('checked', ({ failed, count }) => { // Finished check
|
||||
installs.reset();
|
||||
downloads.reset();
|
||||
|
||||
if (!succeeded) handleFail();
|
||||
else if (updateCount === 0) launchMain();
|
||||
if (failed) handleFail();
|
||||
else if (count === 0) launchMain();
|
||||
});
|
||||
|
||||
on('downloaded', ({ failed }) => { // Downloaded all modules
|
||||
toSend = 1;
|
||||
|
||||
if (failed > 0) handleFail();
|
||||
});
|
||||
|
||||
on('installed', check); // Installed all modules
|
||||
|
||||
on('downloading-module', ({ name, cur, total }) => {
|
||||
downloads.record(name, '', cur, total);
|
||||
installs.record(name, 'Waiting');
|
||||
});
|
||||
|
||||
on('downloading-modules-finished', ({ failed }) => {
|
||||
toSend = 1;
|
||||
|
||||
if (failed > 0) handleFail();
|
||||
});
|
||||
|
||||
on('installing-module', ({ name, cur, total }) => {
|
||||
installs.record(name, '', cur, total);
|
||||
|
@ -215,10 +217,7 @@ const initOld = () => { // "Old" (not v2 / new, win32 only)
|
|||
on('downloaded-module', segment(downloads));
|
||||
on('installed-module', segment(installs));
|
||||
|
||||
on('installing-modules-finished', check);
|
||||
|
||||
|
||||
on('manual', e => {
|
||||
on('manual', e => { // Host manual update required
|
||||
splashState.details = e.details;
|
||||
sendState('manual');
|
||||
});
|
||||
|
|
|
@ -76,9 +76,8 @@ exports.init = (endpoint, { releaseChannel, version }) => {
|
|||
hostUpdater.on('update-available', () => {
|
||||
log('Modules', 'Host available');
|
||||
|
||||
events.emit('update-check-finished', {
|
||||
succeeded: true,
|
||||
updateCount: 1
|
||||
events.emit('checked', {
|
||||
count: 1
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -103,7 +102,7 @@ exports.init = (endpoint, { releaseChannel, version }) => {
|
|||
hostUpdater.on('error', () => {
|
||||
log('Modules', 'Host error');
|
||||
|
||||
events.emit('update-check-finished', { succeeded: false });
|
||||
events.emit('checked', { failed: true });
|
||||
});
|
||||
|
||||
const platform = process.platform === 'darwin' ? 'osx' : 'linux';
|
||||
|
@ -117,9 +116,8 @@ exports.init = (endpoint, { releaseChannel, version }) => {
|
|||
};
|
||||
|
||||
const hostPassed = (skip = skipModule) => {
|
||||
if (skip) return events.emit('update-check-finished', {
|
||||
succeeded: true,
|
||||
updateCount: 0
|
||||
if (skip) return events.emit('checked', {
|
||||
count: 0
|
||||
});
|
||||
|
||||
log('Modules', 'Host good');
|
||||
|
@ -136,9 +134,8 @@ const checkModules = async () => {
|
|||
} catch (e) {
|
||||
log('Modules', 'Check failed', e);
|
||||
|
||||
return events.emit('update-check-finished', {
|
||||
succeeded: false,
|
||||
updateCount: 0
|
||||
return events.emit('checked', {
|
||||
failed: true
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -156,8 +153,7 @@ const checkModules = async () => {
|
|||
}
|
||||
|
||||
events.emit('update-check-finished', {
|
||||
succeeded: true,
|
||||
updateCount: doing
|
||||
count: doing
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -202,8 +198,7 @@ const downloadModule = async (name, ver) => {
|
|||
downloading.done++;
|
||||
|
||||
if (downloading.done === downloading.total) {
|
||||
events.emit('downloading-modules-finished', {
|
||||
succeeded: downloading.total - downloading.fail,
|
||||
events.emit('downloaded', {
|
||||
failed: downloading.fail
|
||||
});
|
||||
}
|
||||
|
@ -289,8 +284,7 @@ const finishInstall = (name, ver, success) => {
|
|||
if (installing.done === downloading.total) {
|
||||
if (!installing.fail) last = Date.now();
|
||||
|
||||
events.emit('installing-modules-finished', {
|
||||
succeeded: installing.total - installing.fail,
|
||||
events.emit('installed', {
|
||||
failed: installing.fail
|
||||
});
|
||||
|
||||
|
@ -311,13 +305,13 @@ exports.checkForUpdates = () => {
|
|||
|
||||
exports.quitAndInstallUpdates = () => hostUpdater.quitAndInstall();
|
||||
|
||||
const isInstalled = exports.isInstalled = (n, v) => installed[n] && !(v && installed[n].installedVersion !== v);
|
||||
exports.isInstalled = (n, v) => installed[n] && !(v && installed[n].installedVersion !== v);
|
||||
exports.getInstalled = () => ({ ...installed });
|
||||
|
||||
const commitManifest = () => fs.writeFileSync(manifestPath, JSON.stringify(installed, null, 2));
|
||||
|
||||
exports.install = (name, def, { version } = {}) => {
|
||||
if (isInstalled(name, version)) {
|
||||
if (exports.isInstalled(name, version)) {
|
||||
if (!def) events.emit('installed-module', {
|
||||
name,
|
||||
succeeded: true
|
||||
|
|
Loading…
Reference in a new issue