mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-18 10:30:49 +01:00
refactor: get rid of cleanupUids use missing set
This commit is contained in:
@@ -602,7 +602,6 @@ Actors.prune = async () => {
|
||||
let deletionCountNonExisting = 0;
|
||||
let notDeletedDueToLocalContent = 0;
|
||||
const preservedIds = [];
|
||||
const cleanupUids = [];
|
||||
|
||||
await batch.processArray(ids, async (ids) => {
|
||||
const exists = await Promise.all([
|
||||
@@ -652,7 +651,7 @@ Actors.prune = async () => {
|
||||
} catch (err) {
|
||||
winston.error(`Failed to delete user with uid ${uid}: ${err.stack}`);
|
||||
if (err.message === '[[error:no-user]]') {
|
||||
cleanupUids.push(uid);
|
||||
missing.add(uid);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -661,14 +660,6 @@ Actors.prune = async () => {
|
||||
}
|
||||
}));
|
||||
|
||||
if (cleanupUids.length) {
|
||||
await Promise.all([
|
||||
db.sortedSetRemove('usersRemote:lastCrawled', cleanupUids),
|
||||
db.deleteAll(cleanupUids.map(uid => `userRemote:${uid}`)),
|
||||
]);
|
||||
winston.info(`[actors/prune] Cleaned up ${cleanupUids.length} remote users that were not found in the database.`);
|
||||
}
|
||||
|
||||
// Remote categories
|
||||
let counts = await categories.getCategoriesFields(cids, ['topic_count']);
|
||||
counts = counts.map(count => count.topic_count);
|
||||
@@ -688,7 +679,11 @@ Actors.prune = async () => {
|
||||
}));
|
||||
|
||||
deletionCountNonExisting += missing.size;
|
||||
await db.sortedSetRemove('usersRemote:lastCrawled', Array.from(missing));
|
||||
if (missing.size) {
|
||||
await db.sortedSetRemove('usersRemote:lastCrawled', Array.from(missing));
|
||||
winston.info(`[actors/prune] Cleaned up ${missing.size} remote users that were not found in the database.`);
|
||||
}
|
||||
|
||||
// update timestamp in usersRemote:lastCrawled so we don't try to delete users
|
||||
// with content over and over
|
||||
const now = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user