round memory to nearest GB

os.totalmem returns some close-to-GB number. Because of this two
apps with 2GB don't install on 4GB.
This commit is contained in:
girish@cloudron.io
2016-02-25 17:16:11 -08:00
parent 6b67e64bf1
commit 187d4f9ca2

View File

@@ -764,7 +764,8 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
Client.prototype.enoughResourcesAvailable = function (app) {
var needed = app.manifest.memoryLimit || DEFAULT_MEMORY_LIMIT;
var used = this.getInstalledApps().reduce(function (prev, cur) { return prev + (cur.manifest.memoryLimit || DEFAULT_MEMORY_LIMIT); }, 0);
var available = (this.getConfig().memory || 0) - used;
var roundedMemory = Math.round(this.getConfig().memory / (1024 * 1024 * 1024)) * 1024 * 1024 * 1024; // round to nearest GB
var available = (roundedMemory || 0) - used;
return (available - needed) >= 0;
};