feat: use the new DELETE /folder/{id} endpoint in cloud delete_collection

The compute API now exposes folder deletion (cascade: documents and
subfolders; 404 folder_not_found; 409 when descendants are still
queued/processing), so replace the not-supported error with the real call.
The endpoint's own 404 ('Folder not found.') is treated as idempotent
success and drops the cached folder id; a bare route-miss 404 from a server
without the endpoint still raises so the delete can't silently no-op
against old deployments. 409/5xx propagate with the cache intact.
This commit is contained in:
Ray 2026-07-22 13:01:27 +08:00
parent 47c9263379
commit 464d5658dd

View file

@ -209,11 +209,13 @@ class CloudBackend:
except CollectionNotFoundError:
return # already gone — delete is idempotent
if folder_id:
raise PageIndexError(
f"Deleting a cloud collection is not supported by the PageIndex "
f"API — delete folder '{name}' in the dashboard "
"(https://dash.pageindex.ai) instead."
)
try:
self._request("DELETE", f"/folder/{self._enc(folder_id)}/")
except CloudAPIError as e:
# a route-miss 404 (endpoint not deployed) must not read as deleted
if not (e.status_code == 404 and "Folder not found" in str(e)):
raise
self._folder_id_cache.pop(name, None)
# ── Document management ───────────────────────────────────────────────