Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: preserve live resources across concurrent moves and cleanup

Tin69eb107f91e3
diff --git a/apps/api/src/storage/cleanup-queue.ts b/apps/api/src/storage/cleanup-queue.ts
index f92606eab..32de2a9a6 100644
--- a/apps/api/src/storage/cleanup-queue.ts
+++ b/apps/api/src/storage/cleanup-queue.ts
@@ -35,14 +35,16 @@ export async function retryStorageCleanup(): Promise<{ degraded: boolean }> {
where: eq(storageCleanupTable.objectKey, item.objectKey),
});
if (!queued) return;
- const asset = await tx.query.assetTable.findFirst({
- columns: { id: true },
- where: eq(assetTable.objectKey, item.objectKey),
- });
- const background = await tx.query.projectTable.findFirst({
- columns: { id: true },
- where: eq(projectTable.backgroundObjectKey, item.objectKey),
- });
+ const [asset] = await tx
+ .select({ id: assetTable.id })
+ .from(assetTable)
+ .where(eq(assetTable.objectKey, item.objectKey))
+ .for("key share");
+ const [background] = await tx
+ .select({ id: projectTable.id })
+ .from(projectTable)
+ .where(eq(projectTable.backgroundObjectKey, item.objectKey))
+ .for("key share");
if (asset || background) {
await tx
.delete(storageCleanupTable)