diff --git a/src/apps.js b/src/apps.js index 8676536d2..8b882042d 100644 --- a/src/apps.js +++ b/src/apps.js @@ -1162,6 +1162,11 @@ async function validateLocations(locations) { return domainObjectMap; } +async function getCount() { + const result = await database.query('SELECT COUNT(*) AS total FROM apps'); + return result[0].total; +} + async function install(data, auditSource) { assert(data && typeof data === 'object'); assert.strictEqual(typeof auditSource, 'object'); @@ -1237,6 +1242,8 @@ async function install(data, auditSource) { const domainObjectMap = await validateLocations(locations); + if (settings.isDemo() && getCount() >= constants.DEMO_APP_LIMIT) throw new BoxError(BoxError.BAD_STATE, 'Too many installed apps, please uninstall a few and try again'); + const appId = uuid.v4(); debug('Will install app with id : ' + appId); diff --git a/src/constants.js b/src/constants.js index 06f039f48..112c44817 100644 --- a/src/constants.js +++ b/src/constants.js @@ -46,6 +46,7 @@ exports = module.exports = { 'io.github.sickchill.cloudronapp', 'to.couchpota.cloudronapp' ], + DEMO_APP_LIMIT: 20, AUTOUPDATE_PATTERN_NEVER: 'never',