From 26f84c77c4359809a0209023a525100b2b76dd5a Mon Sep 17 00:00:00 2001 From: Oj Date: Fri, 18 Mar 2022 22:49:04 +0000 Subject: [PATCH] [Updater > Module] Rewrite installPendingUpdates to specialize with bootstrapping as only purpose --- src/updater/moduleUpdater.js | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/updater/moduleUpdater.js b/src/updater/moduleUpdater.js index f3e0f13..b05dbcb 100644 --- a/src/updater/moduleUpdater.js +++ b/src/updater/moduleUpdater.js @@ -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'); }; \ No newline at end of file