mirror of https://github.com/certd/certd
perf: 优化pipeline删除时,删除其他history
parent
f78ae93eed
commit
b4252033d5
|
@ -18,7 +18,9 @@ export interface IFileStore {
|
||||||
|
|
||||||
export class FileStore {
|
export class FileStore {
|
||||||
rootDir: string;
|
rootDir: string;
|
||||||
|
// pipelineId
|
||||||
scope: string;
|
scope: string;
|
||||||
|
// historyId
|
||||||
parent: string;
|
parent: string;
|
||||||
constructor(options?: FileStoreOptions) {
|
constructor(options?: FileStoreOptions) {
|
||||||
this.rootDir = fileUtils.getFileRootDir(options?.rootDir);
|
this.rootDir = fileUtils.getFileRootDir(options?.rootDir);
|
||||||
|
|
|
@ -31,4 +31,8 @@ export class HistoryLogService extends BaseService<HistoryLogEntity> {
|
||||||
}
|
}
|
||||||
await this.repository.delete({ historyId: In(numbers) });
|
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);
|
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);
|
// const storage = new DbStorage(pipeline.userId, this.storageService);
|
||||||
// await storage.remove(pipeline.id);
|
// await storage.remove(pipeline.id);
|
||||||
await super.delete([id]);
|
await super.delete([id]);
|
||||||
|
await this.historyService.deleteByPipelineId(id);
|
||||||
|
await this.historyLogService.deleteByPipelineId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearTriggers(id: number) {
|
async clearTriggers(id: number) {
|
||||||
|
|
Loading…
Reference in New Issue