From 187d4f9ca26e0a7c85d00a439a526bde3ca5e15c Mon Sep 17 00:00:00 2001 From: "girish@cloudron.io" Date: Thu, 25 Feb 2016 17:16:11 -0800 Subject: [PATCH] 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. --- webadmin/src/js/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webadmin/src/js/client.js b/webadmin/src/js/client.js index 7004f0b54..e34f4b366 100644 --- a/webadmin/src/js/client.js +++ b/webadmin/src/js/client.js @@ -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; };