From 8c7f6221129b39348d2007dc8b178da69887ac22 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 21 Jul 2026 18:03:49 +0800 Subject: [PATCH] fix: delete the DB row before the files in delete_document MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit File-first ordering meant a failed DB delete left a listed, 'completed' document whose files were gone — and its surviving file_hash made re-adding the same file dedup to the broken doc. DB-first (the order delete_collection already uses) degrades the same failure to harmless orphan files. --- pageindex/backend/local.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pageindex/backend/local.py b/pageindex/backend/local.py index c522131..3eb3f17 100644 --- a/pageindex/backend/local.py +++ b/pageindex/backend/local.py @@ -245,9 +245,6 @@ class LocalBackend: def delete_document(self, collection: str, doc_id: str) -> None: doc = self._require_document(collection, doc_id) - # DB row first, files after (same order as delete_collection): a failure - # mid-way then leaves harmless orphan files, not a listed document whose - # files are gone. self._storage.delete_document(collection, doc_id) if doc.get("file_path"): Path(doc["file_path"]).unlink(missing_ok=True)