This commit is contained in:
barisusakli
2014-09-16 21:43:11 -04:00
parent aae7f2434d
commit b48d81310c
5 changed files with 93 additions and 75 deletions

View File

@@ -13,7 +13,8 @@ var winston = require('winston'),
meta = require('./meta'),
websockets = require('./socket.io'),
events = require('./events'),
plugins = require('./plugins');
plugins = require('./plugins'),
batch = require('./batch');
(function(ThreadTools) {
@@ -71,26 +72,24 @@ var winston = require('winston'),
}
ThreadTools.purge = function(tid, uid, callback) {
async.parallel({
topic: function(next) {
topics.getTopicFields(tid, ['cid'], next);
},
pids: function(next) {
topics.getPids(tid, next);
}
}, function(err, results) {
batch.processSortedSet('tid:' + tid + ':posts', function(err, pids, next) {
async.eachLimit(pids, 10, posts.purge, next);
}, {alwaysStartAt: 0}, function(err) {
if (err) {
return callback(err);
}
async.parallel([
function(next) {
async.eachLimit(results.pids, 10, posts.purge, next);
},
function(next) {
topics.purge(tid, next);
topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
if (err) {
return callback(err);
}
], callback);
posts.purge(mainPid, function(err) {
if (err) {
return callback(err);
}
topics.purge(tid, callback);
});
});
});
};