Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #254 from braydonf/master
Browse files Browse the repository at this point in the history
Remove free + used space check
  • Loading branch information
braydonf authored Sep 21, 2017
2 parents 96fd457 + d03124f commit 17464f3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 60 deletions.
20 changes: 1 addition & 19 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,7 @@ exports.validateAllocation = function(conf, callback) {
conf.storageAllocation = conf.storageAllocation.toString() + 'B';
}

self.getFreeSpace(conf.storagePath, function(err, free) {
var allocatedSpace = bytes.parse(conf.storageAllocation);
if (err) {
callback(err);
}

self.getDirectorySize(conf.storagePath, function(err, usedSpaceBytes) {
if (err) {
return callback(err);
}

if (allocatedSpace > free + usedSpaceBytes) {
return callback(new Error('Invalid storage size: '+
-(free + usedSpaceBytes - allocatedSpace) +' bytes missing'));
}

return callback(null);
});
});
callback(null);
};

/**
Expand Down
41 changes: 0 additions & 41 deletions test/utils.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,47 +160,6 @@ describe('module:utils', function() {
});
});

it('should callback error if cannot get size', function(done) {
let getFreeSpace = sinon.stub(
utils,
'getFreeSpace'
).callsArgWith(1, null, 1024);
let getDirectorySize = sinon.stub(
utils,
'getDirectorySize'
).callsArgWith(1, new Error('Failed to get size'));
utils.validateAllocation({
storageAllocation: '512B',
storagePath: 'some/directory/path'
}, function(err) {
getFreeSpace.restore();
getDirectorySize.restore();
expect(err.message).to.equal('Failed to get size');
done();
});
});

it('should callback error if invalid', function(done) {
let getFreeSpace = sinon.stub(
utils,
'getFreeSpace'
).callsArgWith(1, null, 512);
let getDirectorySize = sinon.stub(
utils,
'getDirectorySize'
).callsArgWith(1, null, 512);
utils.validateAllocation({
storageAllocation: '2048B',
storagePath: 'some/directory/path'
}, function(err) {
getFreeSpace.restore();
getDirectorySize.restore();
expect(err.message).to.equal(
'Invalid storage size: 1024 bytes missing');
done();
});
});

});

describe('#portIsAvailable', function() {
Expand Down

0 comments on commit 17464f3

Please sign in to comment.