mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
chore: clear file
This commit is contained in:
@@ -34,10 +34,17 @@ export class FileStore {
|
||||
}
|
||||
|
||||
private buildFilePath(filename: string) {
|
||||
const parentDir = path.join(this.rootDir, this.scope + "", dayjs().format("YYYY-MM-DD"), this.parent + "");
|
||||
const parentDir = path.join(this.rootDir, this.scope + "", this.parent + "", dayjs().format("YYYY-MM-DD"));
|
||||
if (!fs.existsSync(parentDir)) {
|
||||
fs.mkdirSync(parentDir, { recursive: true });
|
||||
}
|
||||
return path.join(parentDir, filename);
|
||||
}
|
||||
|
||||
deleteByParent(scope: string, parent: string) {
|
||||
const dir = path.join(this.rootDir, scope, parent);
|
||||
if (fs.existsSync(dir)) {
|
||||
fs.unlinkSync(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ export * from "./executor";
|
||||
export * from "./run-history";
|
||||
export * from "./context";
|
||||
export * from "./storage";
|
||||
export * from "./file-store";
|
||||
|
||||
@@ -78,6 +78,12 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
linkFile(file: FileItem) {
|
||||
this._result.files!.push({
|
||||
...file,
|
||||
id: uuidv4(),
|
||||
});
|
||||
}
|
||||
saveFile(filename: string, file: Buffer) {
|
||||
const filePath = this.ctx.fileStore.writeFile(filename, file);
|
||||
this._result.files!.push({
|
||||
|
||||
Reference in New Issue
Block a user