From 60d112a6ad544243f55b87497192a43c05da5c1e Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Tue, 15 Oct 2024 02:31:52 +0200 Subject: [PATCH] [backend/core] Fix user purge job processor errors (ISH-525) --- Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs b/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs index a72074da..5c949cad 100644 --- a/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs +++ b/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs @@ -309,7 +309,7 @@ public class BackgroundTaskQueue(int parallelism) } var fileIdQ = db.DriveFiles.Where(p => p.User == user).Select(p => p.Id); - var fileIdCnt = fileIdQ.CountAsync(token); + var fileIdCnt = await fileIdQ.CountAsync(token); var fileIds = fileIdQ.AsChunkedAsyncEnumerable(50, p => p); logger.LogDebug("Removing {count} files for user {id}", fileIdCnt, user.Id); await foreach (var id in fileIds) @@ -321,16 +321,18 @@ public class BackgroundTaskQueue(int parallelism) } var noteQ = db.Notes.Where(p => p.User == user).Select(p => p.Id); - var noteCnt = noteQ.CountAsync(token); + var noteCnt = await noteQ.CountAsync(token); var noteIds = noteQ.AsChunkedAsyncEnumerable(50, p => p); logger.LogDebug("Removing {count} notes for user {id}", noteCnt, user.Id); await foreach (var id in noteIds) { - var note = await db.Notes.AsNoTracking() + var note = await db.Notes .IncludeCommonProperties() .FirstOrDefaultAsync(p => p.Id == id, cancellationToken: token); if (note != null) await noteSvc.DeleteNoteAsync(note); + + db.ChangeTracker.Clear(); } logger.LogDebug("User {id} purged successfully", jobData.UserId);