From 3de6cf003e40690b55f18763275f0920d8e780ce Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sat, 10 Jul 2021 19:02:24 +0200 Subject: :wheelchair: use fs sync for backwards compatiblity --- src/util/FileStorage.ts | 10 +++++----- 1 file 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 { 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); } } -- cgit 1.4.1