added checks to skip empty/non-existing hashes

v1.18.x
Barış Soner Uşaklı 10 years ago
parent dfffbace42
commit eaa89a4da7

@ -967,14 +967,18 @@ Upgrade.upgrade = function(callback) {
function(next) {
function upgradeHashToSortedSet(hash, callback) {
db.getObject(hash, function(err, oldHash) {
if (err) {
if (err || !oldHash) {
return callback(err);
}
db.rename(hash, hash + '_old', function(err) {
if (err) {
return callback(err);
}
var keys = Object.keys(oldHash);
if (!keys.length) {
return callback();
}
async.each(keys, function(key, next) {
db.sortedSetAdd(hash, oldHash[key], key, next);
}, callback);

Loading…
Cancel
Save