upgrade script fixes

This commit is contained in:
Barış Soner Uşaklı
2018-01-08 12:03:02 -05:00
parent 9c59abefbf
commit ba56810790
3 changed files with 12 additions and 4 deletions

View File

@@ -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',

View File

@@ -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);

View File

@@ -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();