[Updater > Module] Rewrite installPendingUpdates to specialize with bootstrapping as only purpose

This commit is contained in:
Ducko 2022-03-18 22:49:04 +00:00
parent 82037247e0
commit 26f84c77c4

View file

@ -412,9 +412,7 @@ exports.install = (name, def, { version } = {}) => {
} }
if (def) { if (def) {
installed[name] = { installed[name] = { installedVersion: 0 };
installedVersion: 0
};
return commitManifest(); return commitManifest();
} }
@ -423,31 +421,20 @@ exports.install = (name, def, { version } = {}) => {
}; };
exports.installPendingUpdates = () => { exports.installPendingUpdates = () => {
const todo = [];
if (bootstrapping) { if (bootstrapping) {
let modules = {}; log('Modules', 'Bootstrapping...');
try { try {
modules = JSON.parse(fs.readFileSync(bootstrapPath)); for (const m in JSON.parse(fs.readFileSync(bootstrapPath))) { // Read [resources]/bootstrap/manifest.json, with "moduleName": version (always 0)
} catch (e) { } installed[m] = { installedVersion: 0 }; // Set initial
installModule(m, 0, join(bootstrapPath, m)); // Intentional invalid path
for (const name in modules) {
installed[name] = {
installedVersion: 0
};
todo.push([ name, modules[name], join(bootstrapPath, '..', name + '.zip') ]);
} }
} catch (e) {
log('Modules', 'Bootstrap fail', e);
} }
if (todo.length > 0) { return;
log('Modules', bootstrapping ? 'Bootstrapping' : 'Installing'); }
for (const x of todo) installModule(...x);
} else {
log('Modules', 'Nothing to install');
events.emit('no-pending-updates'); events.emit('no-pending-updates');
}
}; };