返回提交历史
Modified
src/routes/cache.ts
+4
-2
XFEstudio/XFESpaceNinjaServer
chore: handle stripped assets that are not rooted at "0" (#4383)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4383 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
e71ae2bf
代码差异
1 个文件
+4
-2
@@ -7,11 +7,13 @@ cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res)
7
7
res.sendFile(`static/data/H.Cache.bin`, { root: "./" });
8
8
});
9
9
10
cacheRouter.get(/^\/0\/.+!.+$/, async (req, res) => {
10
const strippedAssetsDir = "static/data/0"; // If users have the stripped assets repo checked out, it's at this path.
11
12
cacheRouter.get(/^\/0(?:_[a-z]{2})?\/.+!.+$/, async (req, res) => {
11
13
try {
12
14
const dir = req.path.substring(0, req.path.lastIndexOf("/"));
13
15
const file = req.path.substring(dir.length + 1);
14
const filePath = `static/data${dir}/${file}`;
16
const filePath = `${strippedAssetsDir}${dir}/${file}`;
15
17
16
18
// Return file if we have it
17
19
await fs.access(filePath);