mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 12:55:44 +02: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 deletionCountNonExisting = 0;
|
||||||
let notDeletedDueToLocalContent = 0;
|
let notDeletedDueToLocalContent = 0;
|
||||||
const preservedIds = [];
|
const preservedIds = [];
|
||||||
const cleanupUids = [];
|
|
||||||
|
|
||||||
await batch.processArray(ids, async (ids) => {
|
await batch.processArray(ids, async (ids) => {
|
||||||
const exists = await Promise.all([
|
const exists = await Promise.all([
|
||||||
@@ -652,7 +651,7 @@ Actors.prune = async () => {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
winston.error(`Failed to delete user with uid ${uid}: ${err.stack}`);
|
winston.error(`Failed to delete user with uid ${uid}: ${err.stack}`);
|
||||||
if (err.message === '[[error:no-user]]') {
|
if (err.message === '[[error:no-user]]') {
|
||||||
cleanupUids.push(uid);
|
missing.add(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
// Remote categories
|
||||||
let counts = await categories.getCategoriesFields(cids, ['topic_count']);
|
let counts = await categories.getCategoriesFields(cids, ['topic_count']);
|
||||||
counts = counts.map(count => count.topic_count);
|
counts = counts.map(count => count.topic_count);
|
||||||
@@ -688,7 +679,11 @@ Actors.prune = async () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
deletionCountNonExisting += missing.size;
|
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
|
// update timestamp in usersRemote:lastCrawled so we don't try to delete users
|
||||||
// with content over and over
|
// with content over and over
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|||||||
Reference in New Issue
Block a user