Fix usage of config.memory

This commit is contained in:
Girish Ramakrishnan
2019-12-20 10:02:01 -08:00
parent 7d70060962
commit 3f3ec9ef9a
2 changed files with 28 additions and 17 deletions

View File

@@ -63,9 +63,6 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
// variable available only here to avoid this._property pattern
var token = null;
// Keep this in sync with docs and constants.js, docker.js
var DEFAULT_MEMORY_LIMIT = 1024 * 1024 * 256;
function ClientError(statusCode, messageOrObject) {
Error.call(this);
this.name = this.constructor.name;
@@ -218,8 +215,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
update: { box: null, apps: null },
progress: {},
region: null,
size: null,
memory: 0
size: null
};
this._installedApps = [];
this._installedAppsById = {};
@@ -1760,16 +1756,6 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
Client.prototype.enoughResourcesAvailable = function (app) {
var needed = app.manifest.memoryLimit || DEFAULT_MEMORY_LIMIT; // RAM+Swap
var used = this.getInstalledApps().reduce(function (prev, cur) { return prev + (cur.memoryLimit || cur.manifest.memoryLimit || DEFAULT_MEMORY_LIMIT); }, 0);
var roundedMemory = Math.round(this.getConfig().memory / (1024 * 1024 * 1024)) * 1024 * 1024 * 1024; // round to nearest GB
var totalMemory = roundedMemory * 1.5; // cloudron-system-setup.sh creates equal amount of swap. 1.5 factor is arbitrary
var available = (totalMemory || 0) - used;
return (available - needed) >= 0;
};
Client.prototype.uploadFile = function (appId, file, progressCallback, callback) {
var fd = new FormData();
fd.append('file', file);