diff --git a/.env.example b/.env.example deleted file mode 100644 index b5e011f17..000000000 --- a/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -STORAGE_LOCATION=files/ -STORAGE_PROVIDER=file -PORT=3003 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e296e974f..5c56d9e3e 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts index 9c9911f3e..c64973060 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 { - 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 { + 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); + } }