Ensure we always have a features object expected by that version
This commit is contained in:
+7
-3
@@ -54,7 +54,7 @@ const apps = require('./apps.js'),
|
||||
|
||||
// These are the default options and will be adjusted once a subscription state is obtained
|
||||
// Keep in sync with appstore/routes/cloudrons.js
|
||||
let gFeatures = {
|
||||
const gFeatures = {
|
||||
appMaxCount: 2,
|
||||
userMaxCount: 5,
|
||||
domainMaxCount: 1,
|
||||
@@ -78,7 +78,9 @@ let gFeatures = {
|
||||
|
||||
// attempt to load feature cache in case appstore would be down
|
||||
const tmp = safe.JSON.parse(safe.fs.readFileSync(paths.FEATURES_INFO_FILE, 'utf8'));
|
||||
if (tmp) gFeatures = tmp;
|
||||
for (const f in gFeatures) {
|
||||
if (typeof tmp[f] !== 'undefined') gFeatures[f] = tmp[f];
|
||||
}
|
||||
|
||||
function getFeatures() {
|
||||
return gFeatures;
|
||||
@@ -148,7 +150,9 @@ 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
|
||||
gFeatures = response.body.features;
|
||||
for (const f in gFeatures) {
|
||||
if (typeof response.body.features[f] !== 'undefined') gFeatures[f] = response.body.features[f];
|
||||
}
|
||||
safe.fs.writeFileSync(paths.FEATURES_INFO_FILE, JSON.stringify(gFeatures), 'utf8');
|
||||
|
||||
return response.body;
|
||||
|
||||
Reference in New Issue
Block a user