[Updater > Module] Rewrite bootstrap, remove installPendingUpdates for simplicity
This commit is contained in:
parent
785bd0a672
commit
5070e01d4e
2 changed files with 8 additions and 26 deletions
|
@ -20,11 +20,7 @@ exports.initSplash = (startMin = false) => {
|
|||
|
||||
launchSplash(startMin);
|
||||
|
||||
if (newUpdater != null) {
|
||||
updateUntilCurrent();
|
||||
} else {
|
||||
moduleUpdater.installPendingUpdates();
|
||||
}
|
||||
if (newUpdater != null) updateUntilCurrent();
|
||||
|
||||
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
|
||||
destroySplash();
|
||||
|
@ -253,7 +249,6 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
|
|||
add('installed-module', segmentCallback(installs));
|
||||
|
||||
add('installing-modules-finished', callbackCheck);
|
||||
add('no-pending-updates', callbackCheck);
|
||||
|
||||
const progressCallback = (tracker) => ({ name, cur, total }) => tracker.record(name, '', cur, total);
|
||||
|
||||
|
@ -267,6 +262,8 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
|
|||
});
|
||||
|
||||
sendState(CHECKING_FOR_UPDATES);
|
||||
|
||||
callbackCheck();
|
||||
};
|
||||
|
||||
const scheduleNextUpdate = (callback = moduleUpdater.checkForUpdates) => { // Used by v1 and v2, default to v1 as used more widely in it
|
||||
|
|
|
@ -10,8 +10,7 @@ const request = require('./request');
|
|||
const events = exports.events = new (require('events').EventEmitter)();
|
||||
exports.INSTALLED_MODULE = 'installed-module'; // Fixes DiscordNative ensureModule as it uses export
|
||||
|
||||
let bootstrapping,
|
||||
skipHost, skipModule,
|
||||
let skipHost, skipModule,
|
||||
remote = {},
|
||||
installed = {},
|
||||
downloading, installing,
|
||||
|
@ -49,8 +48,10 @@ exports.init = (endpoint, { releaseChannel, version }) => {
|
|||
|
||||
try {
|
||||
installed = JSON.parse(fs.readFileSync(manifestPath));
|
||||
} catch (e) {
|
||||
bootstrapping = true;
|
||||
} catch {
|
||||
for (const m in JSON.parse(fs.readFileSync(join(paths.getResources(), 'bootstrap', 'manifest.json')))) { // Read [resources]/bootstrap/manifest.json, with "moduleName": version (always 0)
|
||||
installed[m] = { installedVersion: 0 }; // Set initial version as 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -339,8 +340,6 @@ const finishInstall = (name, ver, success) => {
|
|||
});
|
||||
|
||||
resetTracking();
|
||||
|
||||
bootstrapping = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -392,18 +391,4 @@ exports.install = (name, def, { version } = {}) => {
|
|||
}
|
||||
|
||||
downloadModule(name, version ?? remote[name] ?? 0);
|
||||
};
|
||||
|
||||
exports.installPendingUpdates = () => {
|
||||
if (bootstrapping) {
|
||||
log('Modules', 'Bootstrapping...');
|
||||
|
||||
for (const m in JSON.parse(fs.readFileSync(join(paths.getResources(), 'bootstrap', 'manifest.json')))) { // Read [resources]/bootstrap/manifest.json, with "moduleName": version (always 0)
|
||||
installed[m] = { installedVersion: 0 }; // Set initial version as 0
|
||||
}
|
||||
|
||||
return exports.checkForUpdates();
|
||||
}
|
||||
|
||||
events.emit('no-pending-updates');
|
||||
};
|
Loading…
Reference in a new issue