From 6569ea514f9654cbe7982aeddd99310ff2bcb4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 12 Mar 2026 12:49:42 -0400 Subject: [PATCH] refactor: get rid of cleanupUids use missing set --- src/activitypub/actors.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/activitypub/actors.js b/src/activitypub/actors.js index 90fadfe628..d1dc7fa067 100644 --- a/src/activitypub/actors.js +++ b/src/activitypub/actors.js @@ -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();