diff --git a/bin/omarchy-cn-ai-secret b/bin/omarchy-cn-ai-secret index f6423c81..e151eeb7 100755 --- a/bin/omarchy-cn-ai-secret +++ b/bin/omarchy-cn-ai-secret @@ -39,8 +39,9 @@ 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; a failed purge fails the set - if pass_ok && pass show "omarchycn/ai/$provider" > /dev/null 2>&1; then + # through to an outdated key; a failed purge fails the set. + # Existence check is decryption-free (store file on disk). + if pass_ok && [[ -f ${PASSWORD_STORE_DIR:-$HOME/.password-store}/omarchycn/ai/$provider.gpg ]]; then if ! pass rm -f "omarchycn/ai/$provider" > /dev/null; then echo "存储成功但 pass 中的旧副本清除失败,请手动执行: pass rm omarchycn/ai/$provider" >&2 exit 1