summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-07-10 19:02:24 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-07-10 19:02:24 +0200
commit3de6cf003e40690b55f18763275f0920d8e780ce (patch)
tree912cddb0a058155a4f815651b03d19a2159911c3
parentMerge pull request #4 from jhcpeixoto/master (diff)
downloadserver-3de6cf003e40690b55f18763275f0920d8e780ce.tar.xz
:wheelchair: use fs sync for backwards compatiblity
-rw-r--r--src/util/FileStorage.ts10
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);
 	}
 }