Secret: purge failure fails set, unreachable service fails rm

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:26:38 -04:00
co-authored by Claude Fable 5
parent bfef3e5c1e
commit f9f25119d0
+8 -4
View File
@@ -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