add apps.getMemoryLimit

This commit is contained in:
Girish Ramakrishnan
2021-01-20 12:12:14 -08:00
parent a14dbbe77a
commit 4d482d11ee
2 changed files with 17 additions and 8 deletions

View File

@@ -63,6 +63,7 @@ exports = module.exports = {
getDataDir,
getIconPath,
getMemoryLimit,
downloadFile,
uploadFile,
@@ -445,6 +446,20 @@ function getIconPath(app, options, callback) {
callback(new BoxError(BoxError.NOT_FOUND, 'No icon'));
}
function getMemoryLimit(app) {
assert.strictEqual(typeof app, 'object');
let memoryLimit = app.memoryLimit || app.manifest.memoryLimit || 0;
if (memoryLimit === -1) { // unrestricted
memoryLimit = 0;
} else if (memoryLimit === 0 || memoryLimit < constants.DEFAULT_MEMORY_LIMIT) { // ensure we never go below minimum (in case we change the default)
memoryLimit = constants.DEFAULT_MEMORY_LIMIT;
}
return memoryLimit;
}
function postProcess(app, domainObjectMap) {
let result = {};
for (let portName in app.portBindings) {