summary refs log tree commit diff
path: root/src/util/FileStorage.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-07 18:52:22 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-07 18:52:22 +0200
commitb4e409f5c6f781a78737ba7b13d57441a874459c (patch)
tree63eb850400fec72f349e5cb1b665a32e6401bf1b /src/util/FileStorage.ts
parent:sparkles: add asset routes (diff)
downloadserver-b4e409f5c6f781a78737ba7b13d57441a874459c.tar.xz
:bug: fix file storage dir
Diffstat (limited to 'src/util/FileStorage.ts')
-rw-r--r--src/util/FileStorage.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts

index 4a449d5a..453133f3 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts
@@ -1,6 +1,7 @@ import { Storage } from "./Storage"; import fs from "fs"; -import { join, relative } from "path"; +import fse from "fs-extra"; +import { join, relative, dirname } from "path"; import "missing-native-js-functions"; function getPath(path: string) { @@ -23,8 +24,7 @@ export class FileStorage implements Storage { async set(path: string, value: any) { path = getPath(path); - const dir = path.split("/").slice(0, -1).join("/"); - fs.mkdirSync(dir, { recursive: true }); + fse.ensureDirSync(dirname(path)); return fs.writeFileSync(path, value, { encoding: "binary" }); }