[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
1 changed files with 11 additions and 24 deletions

View File

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