diff --git a/lib/index.js b/lib/index.js index 773317301..03e13bc0c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -202,7 +202,7 @@ module.exports = function(config_hash) { app.put('/:package/:tag', can('publish'), media('application/json'), function(req, res, next) { if (typeof(req.body) !== 'string') return next('route') - storage.add_tag(req.params.name, req.body, req.params.tag, function(err) { + storage.add_tag(req.params.package, req.body, req.params.tag, function(err) { if (err) return next(err) res.status(201) return res.send({ @@ -275,11 +275,11 @@ module.exports = function(config_hash) { // at this point document is either created or existed before var t1 = Object.keys(metadata._attachments)[0] create_tarball(t1, metadata._attachments[t1], function(err) { - if (err) return err + if (err) return next(err) var t2 = Object.keys(metadata.versions)[0] create_version(t2, metadata.versions[t2], function(err) { - if (err) return err + if (err) return next(err) res.status(201) return res.send({ diff --git a/lib/local-storage.js b/lib/local-storage.js index 282d7bea9..f8aa2a681 100644 --- a/lib/local-storage.js +++ b/lib/local-storage.js @@ -227,6 +227,7 @@ Storage.prototype.add_version = function(name, version, metadata, tag, callback) Storage.prototype.add_tag = function(name, version, tag, callback) { var self = this + self.update_package(name, function updater(data, cb) { if (data.versions[version] == null) { return cb(new UError({ diff --git a/lib/middleware.js b/lib/middleware.js index bf157facb..e86c91315 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -42,7 +42,7 @@ module.exports.basic_auth = function basic_auth(callback) { function next(err) { // uncomment this to reject users with bad auth headers //return _next.apply(null, arguments) - + // swallow error, user remains unauthorized // set remoteUserError to indicate that user was attempting authentication if (err) req.remoteUserError = err.msg diff --git a/lib/storage.js b/lib/storage.js index ac741982a..ffbbbe6a9 100644 --- a/lib/storage.js +++ b/lib/storage.js @@ -404,7 +404,7 @@ Storage._merge_versions = function(local, up) { // refresh dist-tags for (var i in up['dist-tags']) { - utils.tag_version(local, i, up['dist-tags'][i]) + utils.tag_version(local, up['dist-tags'][i], i) } } diff --git a/lib/utils.js b/lib/utils.js index 719484d62..729ff5ea3 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -90,7 +90,7 @@ module.exports.filter_tarball_urls = function(pkg, req, config) { return pkg } -module.exports.tag_version = function(data, tag, version) { +module.exports.tag_version = function(data, version, tag) { if (tag === 'latest') return switch(typeof(data['dist-tags'][tag])) { case 'string':