From cab71c0539930f4731a8937de19ad704723e45cd Mon Sep 17 00:00:00 2001 From: zxyszx <299979470+zxyszx@users.noreply.github.com> Date: Tue, 4 Aug 2026 02:26:55 +0800 Subject: [PATCH] fix: make snapshot validation shellcheck-safe --- install.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 2d7027e..1427132 100755 --- a/install.sh +++ b/install.sh @@ -766,11 +766,15 @@ restore_update_snapshot() { fi [[ -d "${snapshot}" && -s "${snapshot}/database.db" && -s "${snapshot}/image" && -s "${snapshot}/docker-compose.yml" && -s "${snapshot}/.env" ]] \ || { warn "回滚快照不完整。"; return 1; } - [[ -f "${snapshot}/.env.example" || -f "${snapshot}/env-example.absent" ]] \ - && [[ -f "${snapshot}/newszxcn-email" || -f "${snapshot}/installer.absent" ]] \ - && [[ -f "${snapshot}/nginx.conf" || -f "${snapshot}/nginx.absent" ]] \ - && [[ -d "${snapshot}/certs" || -f "${snapshot}/certs.absent" ]] \ - || { warn "回滚快照缺少文件状态标记。"; return 1; } + if ! { + [[ -f "${snapshot}/.env.example" || -f "${snapshot}/env-example.absent" ]] \ + && [[ -f "${snapshot}/newszxcn-email" || -f "${snapshot}/installer.absent" ]] \ + && [[ -f "${snapshot}/nginx.conf" || -f "${snapshot}/nginx.absent" ]] \ + && [[ -d "${snapshot}/certs" || -f "${snapshot}/certs.absent" ]] + }; then + warn "回滚快照缺少文件状态标记。" + return 1 + fi image="$(tr -d '\r\n' < "${snapshot}/image")" docker image inspect "${image}" >/dev/null 2>&1 || { warn "回滚镜像已不存在:${image}"; return 1; } sqlite_integrity_check "${snapshot}/database.db" "${image}" || { warn "回滚数据库完整性检查未通过。"; return 1; }