summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJoaquim Peixoto <jhcpeixoto@outlook.pt>2021-06-25 20:20:00 +0100
committerJoaquim Peixoto <jhcpeixoto@outlook.pt>2021-06-25 20:20:00 +0100
commit7b84ef1aa027cf9a0defc90044012e625fe2e427 (patch)
tree40d818f25269314aa2904590658bff9df4917fec /src
parent:bug: fix .env file not loading (diff)
downloadserver-7b84ef1aa027cf9a0defc90044012e625fe2e427.tar.xz
FIX MKDIR
Diffstat (limited to 'src')
-rw-r--r--src/util/FileStorage.ts40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts

index 9c9911f3..c6497306 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts
@@ -4,27 +4,27 @@ import { join } from "path"; import "missing-native-js-functions"; 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); - // @ts-ignore - return file; - } catch (error) { - return null; - } - } + async get(path: string): Promise<Buffer | null> { + path = join(process.env.STORAGE_LOCATION || "", path); + try { + const file = await fs.readFile(path); + // @ts-ignore + return file; + } catch (error) { + return null; + } + } - async set(path: string, value: any) { - path = join(process.env.STORAGE_LOCATION || "", path); - const dir = path.split("/").slice(0, -1).join("/"); - await fs.mkdir(dir, { recursive: true }).caught(); + 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(); - return fs.writeFile(path, value, { encoding: "binary" }); - } + return fs.writeFile(path, value, { encoding: "binary" }); + } - async delete(path: string) { - path = join(process.env.STORAGE_LOCATION || "", path); - await fs.unlink(path); - } + async delete(path: string) { + path = join(process.env.STORAGE_LOCATION || "", path); + await fs.unlink(path); + } }