diff --git a/src/upgrade.js b/src/upgrade.js index e517185f2b..46075ff5e9 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -425,14 +425,17 @@ Upgrade.upgrade = function (callback) { 'waterdrop-low.mp3': 'Default | Water drop (low)', }; - async.parallel([ - function (cb) { - var keys = ['chat-incoming', 'chat-outgoing', 'notification']; + db.getObject('settings:sounds', function (err, settings) { + if (err) { + return next(err); + } else if (!settings) { + winston.info(schemaName + ' - done'); + return Upgrade.update(thisSchemaDate, next); + } - db.getObject('settings:sounds', function (err, settings) { - if (err || !settings) { - return cb(err); - } + async.parallel([ + function (cb) { + var keys = ['chat-incoming', 'chat-outgoing', 'notification']; keys.forEach(function (key) { if (settings[key] && settings[key].indexOf(' | ') === -1) { @@ -441,38 +444,38 @@ Upgrade.upgrade = function (callback) { }); meta.configs.setMultiple(settings, cb); - }); - }, - function (cb) { - var keys = ['notificationSound', 'incomingChatSound', 'outgoingChatSound']; + }, + function (cb) { + var keys = ['notificationSound', 'incomingChatSound', 'outgoingChatSound']; + + batch.processSortedSet('users:joindate', function (ids, next) { + async.each(ids, function (uid, next) { + user.getSettings(uid, function (err, settings) { + if (err) { + return next(err); + } - batch.processSortedSet('users:joindate', function (ids, next) { - async.each(ids, function (uid, next) { - user.getSettings(uid, function (err, settings) { - if (err) { - return next(err); - } + keys.forEach(function (key) { + if (settings[key] && settings[key].indexOf(' | ') === -1) { + settings[key] = map[settings[key]] || ''; + } + }); - keys.forEach(function (key) { - if (settings[key] && settings[key].indexOf(' | ') === -1) { - settings[key] = map[settings[key]] || ''; - } + user.saveSettings(uid, settings, next); }); - - user.saveSettings(uid, settings, next); - }); - }, next); - }, cb); - }, - ], function (err) { - if (err) { - return next(err); - } - winston.verbose(schemaName + ' - done'); - Upgrade.update(thisSchemaDate, next); + }, next); + }, cb); + }, + ], function (err) { + if (err) { + return next(err); + } + winston.info(schemaName + ' - done'); + Upgrade.update(thisSchemaDate, next); + }); }); } else { - winston.verbose(schemaName + ' - skipped!'); + winston.info(schemaName + ' - skipped!'); next(); } },