mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Deleting manual executions should defer deleting binary data (#6680)
deleting manual executions should defer deleting binary data
This commit is contained in:
parent
b69d20c12e
commit
462a674d17
|
@ -578,7 +578,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
|
||||||
|
|
||||||
if (isManualMode && !saveManualExecutions && !fullRunData.waitTill) {
|
if (isManualMode && !saveManualExecutions && !fullRunData.waitTill) {
|
||||||
// Data is always saved, so we remove from database
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,11 +66,11 @@ function parseFiltersToQueryBuilder(
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class ExecutionRepository extends Repository<ExecutionEntity> {
|
export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
private executionDataRepository: ExecutionDataRepository;
|
constructor(
|
||||||
|
dataSource: DataSource,
|
||||||
constructor(dataSource: DataSource, executionDataRepository: ExecutionDataRepository) {
|
private readonly executionDataRepository: ExecutionDataRepository,
|
||||||
|
) {
|
||||||
super(ExecutionEntity, dataSource.manager);
|
super(ExecutionEntity, dataSource.manager);
|
||||||
this.executionDataRepository = executionDataRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async findMultipleExecutions(
|
async findMultipleExecutions(
|
||||||
|
@ -238,9 +238,13 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteExecution(executionId: string) {
|
async deleteExecution(executionId: string, deferBinaryDataDeletion = false) {
|
||||||
// TODO: Should this be awaited? Should we add a catch in case it fails?
|
const binaryDataManager = BinaryDataManager.getInstance();
|
||||||
await BinaryDataManager.getInstance().deleteBinaryDataByExecutionIds([executionId]);
|
if (deferBinaryDataDeletion) {
|
||||||
|
await binaryDataManager.markDataForDeletionByExecutionId(executionId);
|
||||||
|
} else {
|
||||||
|
await binaryDataManager.deleteBinaryDataByExecutionIds([executionId]);
|
||||||
|
}
|
||||||
return this.delete({ id: executionId });
|
return this.delete({ id: executionId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue