XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

chore: accept static/data/stripped-assets instead of static/data/0 (#4463)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4463 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

a297f8b0
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +18 -8
Modified UPDATE AND START SERVER.bat +6 -1
@@ -7,7 +7,12 @@ if %errorlevel% == 0 (
7 7 git stash
8 8 git checkout -f origin/main
9 9
10 if exist static\data\0\ (
10 if exist static\data\stripped-assets\ (
11 echo Updating stripped assets...
12 cd static\data\stripped-assets\
13 git pull
14 cd ..\..\..\
15 ) else if exist static\data\0\ (
11 16 echo Updating stripped assets...
12 17 cd static\data\0\
13 18 git pull
Modified UPDATE AND START SERVER.sh +6 -1
@@ -7,7 +7,12 @@ if [ $? -eq 0 ]; then
7 7 git stash
8 8 git checkout -f origin/main
9 9
10 if [ -d "static/data/0/" ]; then
10 if [ -d "static/data/stripped-assets/" ]; then
11 echo "Updating stripped assets..."
12 cd static/data/stripped-assets/
13 git pull
14 cd ../../../
15 elif [ -d "static/data/0/" ]; then
11 16 echo "Updating stripped assets..."
12 17 cd static/data/0/
13 18 git pull
Modified src/routes/cache.ts +6 -6
@@ -1,5 +1,5 @@
1 1 import express from "express";
2 import fs from "fs/promises";
2 import fs from "node:fs";
3 3
4 4 const cacheRouter = express.Router();
5 5
@@ -7,7 +7,7 @@ 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 const strippedAssetsDir = "static/data/0"; // If users have the stripped assets repo checked out, it's at this path.
10 const strippedAssetsDir = fs.existsSync("static/data/0") ? "static/data/0" : "static/data/stripped-assets";
11 11
12 12 cacheRouter.get(/^\/0(?:_[a-z]{2})?\/.+!.+$/, async (req, res) => {
13 13 try {
@@ -16,8 +16,8 @@ cacheRouter.get(/^\/0(?:_[a-z]{2})?\/.+!.+$/, async (req, res) => {
16 16 const filePath = `${strippedAssetsDir}${dir}/${file}`;
17 17
18 18 // Return file if we have it
19 await fs.access(filePath);
20 const data = await fs.readFile(filePath, null);
19 await fs.promises.access(filePath);
20 const data = await fs.promises.readFile(filePath, null);
21 21 res.send(data);
22 22 } catch (err) {
23 23 // 404 if we don't
@@ -40,8 +40,8 @@ cacheRouter.get(/^(\/\/|\/)(SplitCaches|Lotus|Tools|7|7_en)\/.*$/, async (req, r
40 40 const file = req.path.substring(dir.length + 1);
41 41 const filePath = `static/data/content${dir}/${file}`;
42 42 // Return file if we have it
43 await fs.access(filePath);
44 const data = await fs.readFile(filePath, null);
43 await fs.promises.access(filePath);
44 const data = await fs.promises.readFile(filePath, null);
45 45 res.send(data);
46 46 } catch (err) {
47 47 // 404 if we don't