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(next) {
function upgradeHashToSortedSet(hash, callback) { function upgradeHashToSortedSet(hash, callback) {
db.getObject(hash, function(err, oldHash) { db.getObject(hash, function(err, oldHash) {
if (err) { if (err || !oldHash) {
return callback(err); return callback(err);
} }
db.rename(hash, hash + '_old', function(err) { db.rename(hash, hash + '_old', function(err) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
var keys = Object.keys(oldHash); var keys = Object.keys(oldHash);
if (!keys.length) {
return callback();
}
async.each(keys, function(key, next) { async.each(keys, function(key, next) {
db.sortedSetAdd(hash, oldHash[key], key, next); db.sortedSetAdd(hash, oldHash[key], key, next);
}, callback); }, callback);

Loading…
Cancel
Save