flat threadtools.purge

v1.18.x
barisusakli 10 years ago
parent 1caddb6182
commit 9f35a2b251

@ -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) {
batch.processSortedSet('tid:' + tid + ':posts', function(pids, next) { if (!exists) {
async.eachLimit(pids, 10, posts.purge, next); return callback();
}, {alwaysStartAt: 0}, function(err) {
if (err) {
return callback(err);
} }
batch.processSortedSet('tid:' + tid + ':posts', function(pids, next) {
topics.getTopicField(tid, 'mainPid', function(err, mainPid) { async.eachLimit(pids, 10, posts.purge, next);
if (err) { }, {alwaysStartAt: 0}, next);
return callback(err); },
} function(next) {
posts.purge(mainPid, function(err) { topics.getTopicField(tid, 'mainPid', next);
if (err) { },
return callback(err); function(mainPid, next) {
} posts.purge(mainPid, next);
topics.purge(tid, callback); },
}); function(next) {
}); topics.purge(tid, next);
}); }
}); ], callback);
}; };
ThreadTools.lock = function(tid, uid, callback) { ThreadTools.lock = function(tid, uid, callback) {

Loading…
Cancel
Save