Skip to content

Commit

Permalink
Merge branch 'hotfix/0.2.1' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Haering committed Jul 13, 2011
2 parents 6e088b3 + 2ea11fd commit c284433
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/bundles/index.js
Expand Up @@ -372,6 +372,7 @@ BundleManager.prototype.getBundle = function(name, version, callback) {
*/
BundleManager.prototype.remove = function(name, version, callback) {
var self = this;
var locked = false;
var tmpFileManager = managers.getManager('TempFileManager');
var tmpExtractedPath = tmpFileManager.allocate('');
var bundleName = getBundleName(name, version);
Expand All @@ -386,6 +387,7 @@ BundleManager.prototype.remove = function(name, version, callback) {

// Move extracted bundle to temporary directory
function(callback) {
locked = true;
fs.rename(extractedDirPath, tmpExtractedPath, function(err) {
if (err && err.code === 'ENOENT') {
err = new jobs.NotFoundError('Bundle', bundleName);
Expand All @@ -401,13 +403,20 @@ BundleManager.prototype.remove = function(name, version, callback) {
function(callback) {
self.cleanApplication(name, function(err) {
self.releaseLock();
locked = false;
callback(err);
});
},

// Remove the extracted bundle from tmp at our leisure
async.apply(fsutil.rmtree, tmpExtractedPath)
], callback);
],
function(err) {
if (locked) {
self.releaseLock();
}
callback(err);
});
};


Expand Down
9 changes: 9 additions & 0 deletions tests/control/test-bundles.js
Expand Up @@ -261,6 +261,15 @@ exports['test_bundles'] = function(test, assert) {
});
},

// Attempt to delete the same bundle again
function(callback) {
control.bundles.removeBundle(appName, '1.5', function(err) {
var msg = 'Bundle \'' + appName + '@1.5\' does not exist.';
assert.equal(err.message, msg);
callback();
});
},

// List applications (should be two now)
function(callback) {
control.bundles.listApplications(function(err, apps) {
Expand Down

0 comments on commit c284433

Please sign in to comment.