flat threadtools.purge

This commit is contained in:
barisusakli
2015-01-10 17:12:32 -05:00
parent 1caddb6182
commit 9f35a2b251

View File

@@ -73,31 +73,28 @@ var winston = require('winston'),
} }
ThreadTools.purge = function(tid, uid, callback) { ThreadTools.purge = function(tid, uid, callback) {
ThreadTools.exists(tid, function(err, exists) { async.waterfall([
if (err || !exists) { function(next) {
return callback(err); ThreadTools.exists(tid, next);
},
function(exists, next) {
if (!exists) {
return callback();
} }
batch.processSortedSet('tid:' + tid + ':posts', function(pids, next) { batch.processSortedSet('tid:' + tid + ':posts', function(pids, next) {
async.eachLimit(pids, 10, posts.purge, next); async.eachLimit(pids, 10, posts.purge, next);
}, {alwaysStartAt: 0}, function(err) { }, {alwaysStartAt: 0}, next);
if (err) { },
return callback(err); function(next) {
topics.getTopicField(tid, 'mainPid', next);
},
function(mainPid, next) {
posts.purge(mainPid, next);
},
function(next) {
topics.purge(tid, next);
} }
], callback);
topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
if (err) {
return callback(err);
}
posts.purge(mainPid, function(err) {
if (err) {
return callback(err);
}
topics.purge(tid, callback);
});
});
});
});
}; };
ThreadTools.lock = function(tid, uid, callback) { ThreadTools.lock = function(tid, uid, callback) {