mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-01 00:08:53 +02:00
upgrade script fixes
This commit is contained in:
@@ -250,6 +250,7 @@ module.exports = function (Topics) {
|
||||
var topic;
|
||||
var oldCid;
|
||||
var cid = data.cid;
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Topics.exists(tid, next);
|
||||
@@ -262,6 +263,9 @@ module.exports = function (Topics) {
|
||||
},
|
||||
function (topicData, next) {
|
||||
topic = topicData;
|
||||
if (parseInt(cid, 10) === parseInt(topic.cid, 10)) {
|
||||
return next(new Error('[[error:cant-move-topic-to-same-category]]'));
|
||||
}
|
||||
db.sortedSetsRemove([
|
||||
'cid:' + topicData.cid + ':tids',
|
||||
'cid:' + topicData.cid + ':tids:pinned',
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = {
|
||||
var topicData;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getObjectFields('topic:' + tid, ['mainPid', 'cid'], next);
|
||||
db.getObjectFields('topic:' + tid, ['mainPid', 'cid', 'pinned'], next);
|
||||
},
|
||||
function (_topicData, next) {
|
||||
topicData = _topicData;
|
||||
@@ -44,7 +44,11 @@ module.exports = {
|
||||
db.sortedSetAdd('topics:votes', votes, tid, next);
|
||||
},
|
||||
function (next) {
|
||||
db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next);
|
||||
if (parseInt(topicData.pinned, 10) !== 1) {
|
||||
db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
], function (err) {
|
||||
next(err);
|
||||
|
||||
@@ -28,12 +28,12 @@ module.exports = {
|
||||
var downvotes = parseInt(topicData.downvotes, 10) || 0;
|
||||
var votes = upvotes - downvotes;
|
||||
|
||||
async.parallel([
|
||||
async.series([
|
||||
function (next) {
|
||||
db.sortedSetRemove('cid:' + topicData.oldCid + ':tids:votes', tid, next);
|
||||
},
|
||||
function (next) {
|
||||
if (!parseInt(topicData.pinned, 10)) {
|
||||
if (parseInt(topicData.pinned, 10) !== 1) {
|
||||
db.sortedSetAdd('cid:' + topicData.cid + ':tids:votes', votes, tid, next);
|
||||
} else {
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user