diff options
Diffstat (limited to 'src/util/FileStorage.ts')
-rw-r--r-- | src/util/FileStorage.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts index 48b4a6a5..b87c4651 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts @@ -1,5 +1,5 @@ import { Storage } from "./Storage"; -import fs from "fs/promises"; +import fs from "fs"; import { join } from "path"; import "missing-native-js-functions"; @@ -7,7 +7,7 @@ export class FileStorage implements Storage { async get(path: string): Promise<Buffer | null> { path = join(process.env.STORAGE_LOCATION || "", path); try { - const file = await fs.readFile(path); + const file = fs.readFileSync(path); // @ts-ignore return file; } catch (error) { @@ -18,13 +18,13 @@ export class FileStorage implements Storage { async set(path: string, value: any) { path = join(process.env.STORAGE_LOCATION || "", path).replace(/[\\]/g, "/"); const dir = path.split("/").slice(0, -1).join("/"); - await fs.mkdir(dir, { recursive: true }).caught(); + fs.mkdirSync(dir, { recursive: true }); - return fs.writeFile(path, value, { encoding: "binary" }); + return fs.writeFileSync(path, value, { encoding: "binary" }); } async delete(path: string) { path = join(process.env.STORAGE_LOCATION || "", path); - await fs.unlink(path); + fs.unlinkSync(path); } } |