Ensure we start with a default features set if features file cannot be loaded/parsed
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user