Skip to content

Commit

Permalink
fix(core): Deleting manual executions should defer deleting binary da…
Browse files Browse the repository at this point in the history
…ta (#6680)

deleting manual executions should defer deleting binary data
  • Loading branch information
netroy authored and OlegIvaniv committed Aug 3, 2023
1 parent 7e21d6c commit 949937d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/WorkflowExecuteAdditionalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
18 changes: 11 additions & 7 deletions packages/cli/src/databases/repositories/execution.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ function parseFiltersToQueryBuilder(

@Service()
export class ExecutionRepository extends Repository<ExecutionEntity> {
private executionDataRepository: ExecutionDataRepository;

constructor(dataSource: DataSource, executionDataRepository: ExecutionDataRepository) {
constructor(
dataSource: DataSource,
private readonly executionDataRepository: ExecutionDataRepository,
) {
super(ExecutionEntity, dataSource.manager);
this.executionDataRepository = executionDataRepository;
}

async findMultipleExecutions(
Expand Down Expand Up @@ -238,9 +238,13 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
}
}

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 });
}

Expand Down

0 comments on commit 949937d

Please sign in to comment.