From 15a96fb496c67171345a635c7efb4ade21ac685c Mon Sep 17 00:00:00 2001 From: Dean Date: Sun, 13 Nov 2022 18:08:48 +0000 Subject: [PATCH] Fix for attachment cleanup on internal row delete. --- packages/server/src/api/controllers/table/internal.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/controllers/table/internal.ts b/packages/server/src/api/controllers/table/internal.ts index a50009b1f6..d569fd4547 100644 --- a/packages/server/src/api/controllers/table/internal.ts +++ b/packages/server/src/api/controllers/table/internal.ts @@ -142,15 +142,15 @@ export async function destroy(ctx: any) { const tableToDelete = await db.get(ctx.params.tableId) // Delete all rows for that table - const rows = await db.allDocs( + const rowsData = await db.allDocs( getRowParams(ctx.params.tableId, null, { include_docs: true, }) ) await db.bulkDocs( - rows.rows.map((row: any) => ({ ...row.doc, _deleted: true })) + rowsData.rows.map((row: any) => ({ ...row.doc, _deleted: true })) ) - await quotas.removeRows(rows.rows.length, { + await quotas.removeRows(rowsData.rows.length, { tableId: ctx.params.tableId, }) @@ -179,7 +179,9 @@ export async function destroy(ctx: any) { oldTable: null, deletion: true, }) - await cleanupAttachments(tableToDelete, { rows }) + await cleanupAttachments(tableToDelete, { + rows: rowsData.rows.map((row: any) => row.doc), + }) return tableToDelete }