diff --git a/lib/utils.js b/lib/utils.js index 2c9cce2..03c6d89 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -80,10 +80,7 @@ exports.validate = function(config) { exports.validateAllocation = function(conf, callback) { const self = this; - if (conf.storageAllocation && - !conf.storageAllocation.toString().match( - /[0-9]+([Tt]|[Mm]|[Gg]|[Kk])?[Bb]/g - )) { + if (!self._isValidStorageAllocationFormat(conf.storageAllocation)) { return callback( new Error('Invalid storage size specified: '+ conf.storageAllocation) ); @@ -120,6 +117,20 @@ exports.existsSync = function(file) { return true; }; +/** + * Check if StorageAllocation is formatted properly (Size + Unit) + * @param {String} storage - storage Allocation from config + */ +exports._isValidStorageAllocationFormat = function(storageAllocation) { + if (!storageAllocation.toString().match( + /[0-9]+([Tt]|[Mm]|[Gg]|[Kk])?[Bb]/g) + ) { + return false; + } + + return true; +}; + /** * Recursively determines the size of a directory * @param {String} dir - Directory to traverse diff --git a/package.json b/package.json index a8c5c9a..89e17da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "storjshare-daemon", - "version": "3.5.1", + "version": "3.5.2", "description": "daemon + process manager for sharing space on the storj network", "main": "index.js", "bin": {