mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
perf: 优化pipeline删除时,删除其他history
This commit is contained in:
@@ -31,4 +31,8 @@ export class HistoryLogService extends BaseService<HistoryLogEntity> {
|
||||
}
|
||||
await this.repository.delete({ historyId: In(numbers) });
|
||||
}
|
||||
|
||||
async deleteByPipelineId(id: number) {
|
||||
await this.repository.delete({ pipelineId: id });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,4 +142,21 @@ export class HistoryService extends BaseService<HistoryEntity> {
|
||||
});
|
||||
await this.logService.deleteByHistoryIds(ids);
|
||||
}
|
||||
|
||||
async deleteByPipelineId(id: number) {
|
||||
await this.repository.delete({
|
||||
pipelineId: id,
|
||||
});
|
||||
|
||||
try {
|
||||
const fileStore = new FileStore({
|
||||
rootDir: this.certdConfig.fileRootDir,
|
||||
scope: id + '',
|
||||
parent: '0',
|
||||
});
|
||||
fileStore.deleteByParent(id + '', '');
|
||||
} catch (e) {
|
||||
logger.error('删除文件失败', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +198,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
// const storage = new DbStorage(pipeline.userId, this.storageService);
|
||||
// await storage.remove(pipeline.id);
|
||||
await super.delete([id]);
|
||||
await this.historyService.deleteByPipelineId(id);
|
||||
await this.historyLogService.deleteByPipelineId(id);
|
||||
}
|
||||
|
||||
async clearTriggers(id: number) {
|
||||
|
||||
Reference in New Issue
Block a user