From 835b380a5e008378b2e5fe78b70404efb12f0f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 17 Jul 2023 21:00:36 +0200 Subject: [PATCH] deleting manual executions should defer deleting binary data --- .../cli/src/WorkflowExecuteAdditionalData.ts | 2 +- .../repositories/execution.repository.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index b55d8a039fe67..2ad83109fc03b 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -578,7 +578,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks { if (isManualMode && !saveManualExecutions && !fullRunData.waitTill) { // Data is always saved, so we remove from database - await Container.get(ExecutionRepository).deleteExecution(this.executionId); + await Container.get(ExecutionRepository).deleteExecution(this.executionId, true); return; } diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index 5db7130aca476..07215d4701908 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -66,11 +66,11 @@ function parseFiltersToQueryBuilder( @Service() export class ExecutionRepository extends Repository { - private executionDataRepository: ExecutionDataRepository; - - constructor(dataSource: DataSource, executionDataRepository: ExecutionDataRepository) { + constructor( + dataSource: DataSource, + private readonly executionDataRepository: ExecutionDataRepository, + ) { super(ExecutionEntity, dataSource.manager); - this.executionDataRepository = executionDataRepository; } async findMultipleExecutions( @@ -238,9 +238,13 @@ export class ExecutionRepository extends Repository { } } - async deleteExecution(executionId: string) { - // TODO: Should this be awaited? Should we add a catch in case it fails? - await BinaryDataManager.getInstance().deleteBinaryDataByExecutionIds([executionId]); + async deleteExecution(executionId: string, deferBinaryDataDeletion = false) { + const binaryDataManager = BinaryDataManager.getInstance(); + if (deferBinaryDataDeletion) { + await binaryDataManager.markDataForDeletionByExecutionId(executionId); + } else { + await binaryDataManager.deleteBinaryDataByExecutionIds([executionId]); + } return this.delete({ id: executionId }); }