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;
};
export interface IFileStore {
readFile(filePath: string): Buffer | null;
writeFile(filename: string, file: Buffer): string;
deleteByParent(scope: string, parent: string): void;
}
export class FileStore {
rootDir: string;
scope: string;
@ -35,7 +41,7 @@ export class FileStore {
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"));
if (!fs.existsSync(parentDir)) {
fs.mkdirSync(parentDir, { recursive: true });