some checks for purge

This commit is contained in:
barisusakli
2014-10-31 22:04:09 -04:00
parent d43e8beb60
commit fcc42883ab
5 changed files with 47 additions and 28 deletions

View File

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