0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

fixing crash on bad tags

This commit is contained in:
Alex Kocharin 2013-12-10 13:55:35 +04:00
parent 3617a91f87
commit d149252a3b

View file

@ -151,10 +151,17 @@ Storage.prototype.update_versions = function(name, newdata, callback) {
}
}
for (var tag in newdata['dist-tags']) {
// if tag is updated to reference latter version, that's fine
var need_change =
(data['dist-tags'][tag] == null) ||
(!semver.gte(newdata['dist-tags'][tag], data['dist-tags'][tag]))
if (!Array.isArray(data['dist-tags'][tag]) || data['dist-tags'][tag].length != newdata['dist-tags'][tag].length) {
// backward compat
var need_change = true
} else {
for (var i=0; i<data['dist-tags'][tag].length; i++) {
if (data['dist-tags'][tag][i] != newdata['dist-tags'][tag][i]) {
var need_change = true
break
}
}
}
if (need_change) {
change = true