Skip to content

Commit

Permalink
Allow overwriting with valid _rev
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Mar 28, 2011
1 parent 4842aa4 commit b701400
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion registry/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,15 @@ ddoc.updates.package = function (doc, req) {
if (!semver.valid(ver)) {
return error("invalid version: "+ver)
}

if ((ver in doc.versions) || (semver.clean(ver) in doc.versions)) {
// attempting to overwrite an existing version.
// not supported at this time.
return error("cannot modify existing version")
if (!req.query.rev || req.query.rev !== doc._rev) {
return error("cannot modify existing version")
}
}

var body = JSON.parse(req.body)
if (!valid.name(body.name)) {
return error( "Invalid name: "+JSON.stringify(body.name))
Expand Down

0 comments on commit b701400

Please sign in to comment.