Secret: decryption-free pass existence check for purge

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
2026-08-24 20:27:49 -04:00
co-authored by Claude Fable 5
parent f9f25119d0
commit 8c3ef3d884
+3 -2
View File
@@ -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