summary refs log tree commit diff
path: root/src/cdn/util/FileStorage.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-01-20 18:10:47 +1100
committerGitHub <noreply@github.com>2023-01-20 18:10:47 +1100
commit084dc0be08555891cad4c2bb984822a62ec5ec9f (patch)
treeed2ca0fafefa2224ae32761f955f63935422a97d /src/cdn/util/FileStorage.ts
parentfix: route file regex (#956) (diff)
downloadserver-084dc0be08555891cad4c2bb984822a62ec5ec9f.tar.xz
Add ESLint (#941)
* Add eslint, switch to lint-staged for precommit

* Fix all ESLint errors

* Update GH workflow to check prettier and eslint
Diffstat (limited to 'src/cdn/util/FileStorage.ts')
-rw-r--r--src/cdn/util/FileStorage.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cdn/util/FileStorage.ts b/src/cdn/util/FileStorage.ts

index c8473e30..ee087c85 100644 --- a/src/cdn/util/FileStorage.ts +++ b/src/cdn/util/FileStorage.ts
@@ -28,7 +28,7 @@ import ExifTransformer from "exif-be-gone"; function getPath(path: string) { // STORAGE_LOCATION has a default value in start.ts const root = process.env.STORAGE_LOCATION || "../"; - var filename = join(root, path); + const filename = join(root, path); if (path.indexOf("\0") !== -1 || !filename.startsWith(root)) throw new Error("invalid path"); @@ -51,15 +51,15 @@ export class FileStorage implements Storage { } } - async set(path: string, value: any) { + async set(path: string, value: Buffer) { path = getPath(path); if (!fs.existsSync(dirname(path))) fs.mkdirSync(dirname(path), { recursive: true }); - value = Readable.from(value); + const ret = Readable.from(value); const cleaned_file = fs.createWriteStream(path); - return value.pipe(new ExifTransformer()).pipe(cleaned_file); + ret.pipe(new ExifTransformer()).pipe(cleaned_file); } async delete(path: string) {