♿ use fs sync for backwards compatiblity
This commit is contained in:
parent
5bfdad897b
commit
3de6cf003e
@ -1,5 +1,5 @@
|
||||
import { Storage } from "./Storage";
|
||||
import fs from "fs/promises";
|
||||
import fs from "fs";
|
||||
import { join } from "path";
|
||||
import "missing-native-js-functions";
|
||||
|
||||
@ -7,7 +7,7 @@ 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);
|
||||
const file = fs.readFileSync(path);
|
||||
// @ts-ignore
|
||||
return file;
|
||||
} catch (error) {
|
||||
@ -18,13 +18,13 @@ export class FileStorage implements Storage {
|
||||
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();
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
|
||||
return fs.writeFile(path, value, { encoding: "binary" });
|
||||
return fs.writeFileSync(path, value, { encoding: "binary" });
|
||||
}
|
||||
|
||||
async delete(path: string) {
|
||||
path = join(process.env.STORAGE_LOCATION || "", path);
|
||||
await fs.unlink(path);
|
||||
fs.unlinkSync(path);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user