summary refs log tree commit diff
path: root/src/cdn/util/FileStorage.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/cdn/util/FileStorage.ts')
-rw-r--r--src/cdn/util/FileStorage.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/cdn/util/FileStorage.ts b/src/cdn/util/FileStorage.ts

index 6f01b3c5..ff7a56ee 100644 --- a/src/cdn/util/FileStorage.ts +++ b/src/cdn/util/FileStorage.ts
@@ -74,4 +74,17 @@ export class FileStorage implements Storage { //TODO we should delete the parent directory if empty fs.unlinkSync(getPath(path)); } + + async exists(path: string) { + return fs.existsSync(getPath(path)); + } + + async move(path: string, newPath: string) { + path = getPath(path); + newPath = getPath(newPath); + + if (!fs.existsSync(dirname(newPath))) fs.mkdirSync(dirname(newPath), { recursive: true }); + + fs.renameSync(path, newPath); + } }