summary refs log tree commit diff
path: root/src/util/FileStorage.ts
diff options
context:
space:
mode:
authorJoaquim Peixoto <jhcpeixoto@outlook.pt>2021-06-25 20:26:34 +0100
committerJoaquim Peixoto <jhcpeixoto@outlook.pt>2021-06-25 20:26:34 +0100
commit1a62f1dd8e77220bf86526349ae0ac54e0336464 (patch)
tree30c9f3ac5fa90eaf19adac4de5dbee0432102cbd /src/util/FileStorage.ts
parentFIX MKDIR (diff)
downloadserver-1a62f1dd8e77220bf86526349ae0ac54e0336464.tar.xz
FIXS
Diffstat (limited to '')
-rw-r--r--src/util/FileStorage.ts42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts

index c6497306..42b32528 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).replace(/[\\]/g, "/"); - 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); + } +} \ No newline at end of file