From ca0e31e4ece96a0f054437d1df3f53a4c28528fa Mon Sep 17 00:00:00 2001 From: bo0tzz Date: Tue, 23 Jun 2026 11:12:26 +0200 Subject: [PATCH] fix: GC entries without lastDownloadedAt --- tasks/cleanup/cache-entries.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tasks/cleanup/cache-entries.ts b/tasks/cleanup/cache-entries.ts index c670305..4fe985d 100644 --- a/tasks/cleanup/cache-entries.ts +++ b/tasks/cleanup/cache-entries.ts @@ -21,8 +21,15 @@ export default defineTask({ while (true) { const storageLocations = await db .selectFrom('storage_locations') - .select(['folderName', 'id']) - .where('lastDownloadedAt', '<', xDaysAgo) + .innerJoin('cache_entries', 'cache_entries.locationId', 'storage_locations.id') + .select(['storage_locations.folderName', 'storage_locations.id']) + .where((eb) => + eb( + eb.fn.coalesce('storage_locations.lastDownloadedAt', 'cache_entries.updatedAt'), + '<', + xDaysAgo, + ), + ) .limit(itemsPerPage) .offset(page * itemsPerPage) .execute()