From 8c3ef3d884f001a98be2db89d06d02c617a2bc36 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:27:49 -0400 Subject: [PATCH] Secret: decryption-free pass existence check for purge Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp --- bin/omarchy-cn-ai-secret | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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