pull/101/head
xiaojunnuo 2024-07-17 01:33:55 +08:00
parent 3b19bfb429
commit 4813872bcc
1 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,12 @@ export type FileStoreOptions = {
parent: string; parent: string;
}; };
export interface IFileStore {
readFile(filePath: string): Buffer | null;
writeFile(filename: string, file: Buffer): string;
deleteByParent(scope: string, parent: string): void;
}
export class FileStore { export class FileStore {
rootDir: string; rootDir: string;
scope: string; scope: string;
@ -35,7 +41,7 @@ export class FileStore {
return localPath; return localPath;
} }
private buildFilePath(filename: string) { protected buildFilePath(filename: string) {
const parentDir = path.join(this.rootDir, this.scope + "", this.parent + "", dayjs().format("YYYY-MM-DD")); const parentDir = path.join(this.rootDir, this.scope + "", this.parent + "", dayjs().format("YYYY-MM-DD"));
if (!fs.existsSync(parentDir)) { if (!fs.existsSync(parentDir)) {
fs.mkdirSync(parentDir, { recursive: true }); fs.mkdirSync(parentDir, { recursive: true });