From a55623796390664eb1886cd5517d2b4764daf674 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 10 Jun 2025 09:34:15 +0200 Subject: [PATCH] Ensure we start with a default features set if features file cannot be loaded/parsed --- src/appstore.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/appstore.js b/src/appstore.js index 599881d74..98152facd 100644 --- a/src/appstore.js +++ b/src/appstore.js @@ -69,8 +69,11 @@ let gFeatures = null; function getFeatures() { if (gFeatures === null) { const tmp = safe.JSON.parse(safe.fs.readFileSync(paths.FEATURES_INFO_FILE, 'utf8')); - if (!tmp) return DEFAULT_FEATURES; - gFeatures = Object.assign({}, DEFAULT_FEATURES); + if (!tmp) { + gFeatures = Object.assign({}, DEFAULT_FEATURES); + return DEFAULT_FEATURES; + } + for (const f in DEFAULT_FEATURES) { if (f in tmp) gFeatures[f] = tmp[f]; if (tmp[f] === null) gFeatures[f] = 100000; // null essentially means unlimited @@ -112,6 +115,7 @@ async function getSubscription() { if (response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unknown error: ${response.status} ${JSON.stringify(response.body)}`); // update the features cache + getFeatures(); for (const f in gFeatures) { if (typeof response.body.features[f] !== 'undefined') gFeatures[f] = response.body.features[f]; if (response.body.features[f] === null) gFeatures[f] = 100000; // null essentially means unlimited