Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
remove tags on unpublish
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 9, 2013
1 parent 3dab321 commit b099004
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion controllers/registry/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,10 @@ exports.removeAll = function (req, res, next) {
}
Total.plusDeleteModule(utility.noop);
Module.removeByName(name, ep.done('remove'));
Module.removeTags(name, ep.done('removeTags'));
});

ep.all('list', 'remove', function (mods) {
ep.all('list', 'remove', 'removeTags', function (mods) {
var keys = [];
for (var i = 0; i < mods.length; i++) {
var key = urlparse(mods[i].dist_tarball).path;
Expand Down
6 changes: 6 additions & 0 deletions proxy/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ exports.getByTag = function (name, tag, callback) {
});
};

var DELETE_TAGS_SQL = 'DELETE FROM tag WHERE name=?;';

exports.removeTags = function (name, callback) {
mysql.query(DELETE_TAGS_SQL, [name], callback);
};

var SELECT_ALL_TAGS_SQL = 'SELECT tag, version, gmt_modified FROM tag WHERE name=?;';

exports.listTags = function (name, callback) {
Expand Down
9 changes: 7 additions & 2 deletions test/controllers/registry/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ describe('controllers/registry/module.test.js', function () {
var lastRev;

before(function (done) {
// clean up testputmodule
Module.removeByName('testputmodule', done);
// unpublish testputmodule
request(app)
.del('/' + pkg.name + '/-rev/1')
.set('authorization', baseauth)
.end(function (err, res) {
done();
});
});

it('should try to add not exists module return 201', function (done) {
Expand Down

0 comments on commit b099004

Please sign in to comment.