summary refs log tree commit diff
path: root/cdn/src
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-07-19 07:21:26 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-09 23:28:27 +0200
commit279ec10081f245f4d5bbca8b63485c841f619e35 (patch)
tree4e58b7bb26fa3f5f60cfc8888b9f37a258146083 /cdn/src
parentupdate node types to v18, ditch node-fetch (diff)
downloadserver-279ec10081f245f4d5bbca8b63485c841f619e35.tar.xz
State update, havent tested
Diffstat (limited to 'cdn/src')
-rw-r--r--cdn/src/routes/attachments.ts2
-rw-r--r--cdn/src/routes/avatars.ts2
-rw-r--r--cdn/src/routes/external.ts5
-rw-r--r--cdn/src/routes/role-icons.ts2
-rw-r--r--cdn/src/util/FileStorage.ts6
-rw-r--r--cdn/src/util/Storage.ts6
6 files changed, 12 insertions, 11 deletions
diff --git a/cdn/src/routes/attachments.ts b/cdn/src/routes/attachments.ts

index 2aed752e..3e04fe76 100644 --- a/cdn/src/routes/attachments.ts +++ b/cdn/src/routes/attachments.ts
@@ -2,7 +2,7 @@ import { Router, Response, Request } from "express"; import { Config, Snowflake } from "@fosscord/util"; import { storage } from "../util/Storage"; import FileType from "file-type"; -import { HTTPError } from "lambert-server"; +import { HTTPError } from "@fosscord/util"; import { multer } from "../util/multer"; import imageSize from "image-size"; diff --git a/cdn/src/routes/avatars.ts b/cdn/src/routes/avatars.ts
index 3b521cc3..bbdf42cc 100644 --- a/cdn/src/routes/avatars.ts +++ b/cdn/src/routes/avatars.ts
@@ -2,7 +2,7 @@ import { Router, Response, Request } from "express"; import { Config, Snowflake } from "@fosscord/util"; import { storage } from "../util/Storage"; import FileType from "file-type"; -import { HTTPError } from "lambert-server"; +import { HTTPError } from "@fosscord/util"; import crypto from "crypto"; import { multer } from "../util/multer"; diff --git a/cdn/src/routes/external.ts b/cdn/src/routes/external.ts
index ed44c905..cf02f645 100644 --- a/cdn/src/routes/external.ts +++ b/cdn/src/routes/external.ts
@@ -1,10 +1,9 @@ import { Router, Response, Request } from "express"; import fetch from "node-fetch"; -import { HTTPError } from "lambert-server"; -import { Snowflake } from "@fosscord/util"; +import { HTTPError } from "@fosscord/util"; +import { Snowflake, Config } from "@fosscord/util"; import { storage } from "../util/Storage"; import FileType from "file-type"; -import { Config } from "@fosscord/util"; // TODO: somehow handle the deletion of images posted to the /external route diff --git a/cdn/src/routes/role-icons.ts b/cdn/src/routes/role-icons.ts
index a850db88..dd96c90e 100644 --- a/cdn/src/routes/role-icons.ts +++ b/cdn/src/routes/role-icons.ts
@@ -2,7 +2,7 @@ import { Router, Response, Request } from "express"; import { Config, Snowflake } from "@fosscord/util"; import { storage } from "../util/Storage"; import FileType from "file-type"; -import { HTTPError } from "lambert-server"; +import { HTTPError } from "@fosscord/util"; import crypto from "crypto"; import { multer } from "../util/multer"; diff --git a/cdn/src/util/FileStorage.ts b/cdn/src/util/FileStorage.ts
index 376ce007..ed007abb 100644 --- a/cdn/src/util/FileStorage.ts +++ b/cdn/src/util/FileStorage.ts
@@ -1,8 +1,7 @@ import { Storage } from "./Storage"; import fs from "fs"; -import fse from "fs-extra"; +//import fse from "fs-extra"; import { join, relative, dirname } from "path"; -import "missing-native-js-functions"; import { Readable } from "stream"; import ExifTransformer = require("exif-be-gone"); @@ -36,7 +35,8 @@ export class FileStorage implements Storage { async set(path: string, value: any) { path = getPath(path); - fse.ensureDirSync(dirname(path)); + //fse.ensureDirSync(dirname(path)); + fs.mkdirSync(dirname(path), {recursive: true}); value = Readable.from(value); const cleaned_file = fs.createWriteStream(path); diff --git a/cdn/src/util/Storage.ts b/cdn/src/util/Storage.ts
index 89dd5634..728804a0 100644 --- a/cdn/src/util/Storage.ts +++ b/cdn/src/util/Storage.ts
@@ -1,6 +1,7 @@ import { FileStorage } from "./FileStorage"; import path from "path"; -import fse from "fs-extra"; +//import fse from "fs-extra"; +import fs from "fs"; import { bgCyan, black } from "picocolors"; import { S3 } from "@aws-sdk/client-s3"; import { S3Storage } from "./S3Storage"; @@ -22,7 +23,8 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) { location = path.join(process.cwd(), "files"); } console.log(`[CDN] storage location: ${bgCyan(`${black(location)}`)}`); - fse.ensureDirSync(location); + //fse.ensureDirSync(location); + fs.mkdirSync(location, {recursive: true}); process.env.STORAGE_LOCATION = location; storage = new FileStorage();