Spaces:
Sleeping
Sleeping
key_store: try both Supabase download endpoint forms for robustness
Browse files- app/services/key_store.py +17 -8
app/services/key_store.py
CHANGED
|
@@ -160,14 +160,23 @@ def load_config(tag: str) -> Optional[dict]:
|
|
| 160 |
"""
|
| 161 |
if not (is_configured() and tag):
|
| 162 |
return None
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
|
| 173 |
def delete_config(tag: str) -> bool:
|
|
|
|
| 160 |
"""
|
| 161 |
if not (is_configured() and tag):
|
| 162 |
return None
|
| 163 |
+
obj = _object_path(tag)
|
| 164 |
+
# Supabase exposes private downloads at two equivalent paths depending on
|
| 165 |
+
# version; try the authenticated form first, then the plain one.
|
| 166 |
+
candidates = (
|
| 167 |
+
f"/storage/v1/object/authenticated/{_BUCKET}/{obj}",
|
| 168 |
+
f"/storage/v1/object/{_BUCKET}/{obj}",
|
| 169 |
+
)
|
| 170 |
+
for path in candidates:
|
| 171 |
+
try:
|
| 172 |
+
status, body = _http("GET", f"{_base_url()}{path}", _auth_headers())
|
| 173 |
+
except Exception: # noqa: BLE001 - fail-safe; try the next candidate
|
| 174 |
+
continue
|
| 175 |
+
if 200 <= status < 300 and body:
|
| 176 |
+
payload = decrypt_payload(tag, body)
|
| 177 |
+
if payload is not None:
|
| 178 |
+
return payload
|
| 179 |
+
return None
|
| 180 |
|
| 181 |
|
| 182 |
def delete_config(tag: str) -> bool:
|