From 2524bd20ebd533c3cafc6650e26241a589f467c2 Mon Sep 17 00:00:00 2001 From: Alexander Leitner Date: Mon, 24 Jul 2017 13:16:07 -0400 Subject: [PATCH] try to better handle allocatedspace if not unit is specified --- lib/utils.js | 12 ++++++++---- package.json | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 5b446c3..0140226 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -81,9 +81,13 @@ exports.validateAllocation = function(conf, callback) { const self = this; if (!self._isValidStorageAllocationFormat(conf.storageAllocation)) { - return callback( - new Error('Invalid storage size specified: '+ conf.storageAllocation) - ); + if (isNaN(conf.storageAllocation)) { + return callback( + new Error('Invalid storage size specified: '+ conf.storageAllocation) + ); + } + + conf.storageAllocation = conf.storageAllocation.toString() + 'B'; } self.getFreeSpace(conf.storagePath, function(err, free) { @@ -95,7 +99,7 @@ exports.validateAllocation = function(conf, callback) { } if (allocatedSpace > free + usedSpaceBytes) { - return callback(new Error('Invalid storage size: '+ + return callback(new Error('Invalid storage size: '+ -(free + usedSpaceBytes - allocatedSpace) +' bytes missing')); } diff --git a/package.json b/package.json index 3180513..f7eb855 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "storjshare-daemon", - "version": "3.5.3", + "version": "3.5.4", "description": "daemon + process manager for sharing space on the storj network", "main": "index.js", "bin": {