summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-01-22 13:41:31 +1100
committerGitHub <noreply@github.com>2023-01-22 13:41:31 +1100
commit7b1915ec4813a4f026286ec554092b931d0eb14f (patch)
tree4200a79b9a5ee771c0b6931d0f919594f8e93858 /src
parentAdd ESLint (#941) (diff)
downloadserver-7b1915ec4813a4f026286ec554092b931d0eb14f.tar.xz
Rewrite client cacher (#962)
Diffstat (limited to 'src')
-rw-r--r--src/api/middlewares/TestClient.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/api/middlewares/TestClient.ts b/src/api/middlewares/TestClient.ts

index 10d7e8f1..d229bec9 100644 --- a/src/api/middlewares/TestClient.ts +++ b/src/api/middlewares/TestClient.ts
@@ -25,6 +25,8 @@ import { Config } from "@fosscord/util"; const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "assets"); +let HAS_SHOWN_CACHE_WARNING = false; + export default function TestClient(app: Application) { app.use("/assets", express.static(path.join(ASSET_FOLDER_PATH, "public"))); app.use("/assets", express.static(path.join(ASSET_FOLDER_PATH, "cache"))); @@ -102,15 +104,11 @@ export default function TestClient(app: Application) { assetCache.set(req.params.file, { buffer, response }); - // TODO: I don't like this. Figure out a way to get client cacher to download *all* assets. - if (response.status == 200) { + if (response.status == 200 && !HAS_SHOWN_CACHE_WARNING) { + HAS_SHOWN_CACHE_WARNING = true; console.warn( `[TestClient] Cache miss for file ${req.params.file}! Use 'npm run generate:client' to cache and patch.`, ); - await fs.promises.appendFile( - path.join(ASSET_FOLDER_PATH, "cacheMisses"), - req.params.file + "\n", - ); } return res.send(buffer);