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) {
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);
},
topics.getTopicField(tid, 'mainPid', function(err, mainPid) { function(mainPid, next) {
if (err) { posts.purge(mainPid, next);
return callback(err); },
} function(next) {
posts.purge(mainPid, function(err) { topics.purge(tid, next);
if (err) {
return callback(err);
} }
topics.purge(tid, callback); ], callback);
});
});
});
});
}; };
ThreadTools.lock = function(tid, uid, callback) { ThreadTools.lock = function(tid, uid, callback) {

Loading…
Cancel
Save