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:
@@ -39,8 +39,9 @@ set)
|
|||||||
if secret_service_ok; then
|
if secret_service_ok; then
|
||||||
printf '%s' "$key" | secret-tool store --label "OmarchyCN AI: $provider" service omarchycn key "ai/$provider"
|
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
|
# Purge stale copies in lower-priority backends so get never falls
|
||||||
# through to an outdated key; a failed purge fails the set
|
# through to an outdated key; a failed purge fails the set.
|
||||||
if pass_ok && pass show "omarchycn/ai/$provider" > /dev/null 2>&1; then
|
# 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
|
if ! pass rm -f "omarchycn/ai/$provider" > /dev/null; then
|
||||||
echo "存储成功但 pass 中的旧副本清除失败,请手动执行: pass rm omarchycn/ai/$provider" >&2
|
echo "存储成功但 pass 中的旧副本清除失败,请手动执行: pass rm omarchycn/ai/$provider" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user