From 9da46bc89959632000b57647e65e2f9860b46b23 Mon Sep 17 00:00:00 2001 From: ikuaki1009 Date: Mon, 5 Jun 2023 16:01:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8E=20docker=20=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9=20(#164)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml | 1 + docker/docker-entrypoint.sh | 11 +++++++++-- plugins/genshin/model/user.js | 12 +++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 7a26027..a697a67 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -18,6 +18,7 @@ services: - ./yunzai/genshin_config:/app/Miao-Yunzai/plugins/genshin/config # 公共Cookie,云崽功能配置文件 - ./yunzai/logs:/app/Miao-Yunzai/logs # 日志文件 - ./yunzai/data:/app/Miao-Yunzai/data # 数据文件 + - ./yunzai/temp:/app/Miao-Yunzai/temp # 临时文件 # 以下目录是插件目录,安装完插件后需要手动添加映射(如有其他插件请自行添加) # 映射格式:./yunzai/plugins/<插件目录名>:/app/Miao-Yunzai/plugins/<插件目录名> # - ./yunzai/plugins/example:/app/Miao-Yunzai/plugins/example # 单js插件目录 diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index be14404..022bdc2 100644 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -91,10 +91,10 @@ if [ -d $PY_PLUGIN_PATH"/.git" ]; then echo -e " ${Warn} ${YellowBG} 当前工作区有修改,尝试暂存后更新。${Font}" git add . git stash - git pull origin main --allow-unrelated-histories --rebase + git pull origin v3 --allow-unrelated-histories --rebase git stash pop else - git pull origin main --allow-unrelated-histories + git pull origin v3 --allow-unrelated-histories fi if [[ ! -f "$HOME/.ovo/py.ok" ]]; then @@ -184,4 +184,11 @@ fi echo -e "\n ================ \n ${Info} ${GreenBG} 启动 Miao-Yunzai ${Font} \n ================ \n" +set +e node app +EXIT_CODE=$? + +if [[ $EXIT_CODE != 0 ]]; then + echo -e "\n ================ \n ${Warn} ${YellowBG} 启动 Miao-Yunzai 失败 ${Font} \n ================ \n" + tail -f /dev/null +fi diff --git a/plugins/genshin/model/user.js b/plugins/genshin/model/user.js index 7dd5ca9..d32940d 100644 --- a/plugins/genshin/model/user.js +++ b/plugins/genshin/model/user.js @@ -424,9 +424,15 @@ export default class User extends base { } await user.save() if (fs.existsSync(`./data/MysCookie/${qq}.yaml`)) { - fs.rename(`./data/MysCookie/${qq}.yaml`, `./temp/MysCookieBak/${qq}.yaml`, (err) => { - if (err) console.log(err) - }) + try { + let src = `./data/MysCookie/${qq}.yaml`; + let dest = `./temp/MysCookieBak/${qq}.yaml`; + await fs.promises.unlink(dest).catch((_) => { }); + await fs.promises.copyFile(src, dest); + await fs.promises.unlink(src); + } catch (err) { + console.log(err); + } } count++ }