From 464d5658dd1c3fef47343495c0985097ac25792f Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 22 Jul 2026 13:01:27 +0800 Subject: [PATCH] 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. --- pageindex/backend/cloud.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pageindex/backend/cloud.py b/pageindex/backend/cloud.py index 57c5517..15364b7 100644 --- a/pageindex/backend/cloud.py +++ b/pageindex/backend/cloud.py @@ -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 ───────────────────────────────────────────────