refactor: get rid of cleanupUids use missing set

This commit is contained in:
Barış Soner Uşaklı
2026-03-12 12:49:42 -04:00
parent 10e4d57996
commit 6569ea514f

View File

@@ -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();