From 7b1915ec4813a4f026286ec554092b931d0eb14f Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sun, 22 Jan 2023 13:41:31 +1100 Subject: Rewrite client cacher (#962) --- src/api/middlewares/TestClient.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/api/middlewares') 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); -- cgit 1.5.1