From f9f25119d0bae7d68117d9810903ed41f24146f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Mon, 24 Aug 2026 20:26:38 -0400 Subject: [PATCH] Secret: purge failure fails set, unreachable service fails rm Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp --- bin/omarchy-cn-ai-secret | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/omarchy-cn-ai-secret b/bin/omarchy-cn-ai-secret index e9373ead..f6423c81 100755 --- a/bin/omarchy-cn-ai-secret +++ b/bin/omarchy-cn-ai-secret @@ -39,9 +39,12 @@ set) if secret_service_ok; then printf '%s' "$key" | secret-tool store --label "OmarchyCN AI: $provider" service omarchycn key "ai/$provider" # Purge stale copies in lower-priority backends so get never falls - # through to an outdated key - if pass_ok; then - pass rm -f "omarchycn/ai/$provider" > /dev/null 2>&1 || true + # through to an outdated key; a failed purge fails the set + if pass_ok && pass show "omarchycn/ai/$provider" > /dev/null 2>&1; then + if ! pass rm -f "omarchycn/ai/$provider" > /dev/null; then + echo "存储成功但 pass 中的旧副本清除失败,请手动执行: pass rm omarchycn/ai/$provider" >&2 + exit 1 + fi fi rm -f "$FILE_PATH" echo "Stored in Secret Service (secret-tool)" @@ -84,7 +87,8 @@ rm) removed=1 fi if command -v secret-tool > /dev/null 2>&1 && ! secret_service_ok; then - echo "警告: Secret Service 当前不可达,其中的副本(如有)未被清除" >&2 + echo "Secret Service 不可达,无法确认其中的副本已清除;服务恢复后重新执行 rm" >&2 + exit 1 fi if (( removed == 0 )); then echo "No secret stored for $provider" >&2