fix(core): Deleting manual executions should defer deleting binary data (#6680)

deleting manual executions should defer deleting binary data
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-07-18 10:51:22 +02:00 committed by GitHub
parent b69d20c12e
commit 462a674d17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

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

View file

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