Skip to content

Commit 795c08f

Browse files
committed
feat: mark document as deleted instead of removing from database
1 parent 2502b0f commit 795c08f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

aperag/service/document_service.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from aperag.schema.view_models import DocumentList
4242
from aperag.utils.constant import QuotaType
4343
from aperag.utils.uncompress import SUPPORTED_COMPRESSED_EXTENSIONS
44+
from aperag.utils.utils import utc_now
4445

4546
logger = logging.getLogger(__name__)
4647

@@ -279,10 +280,12 @@ async def _delete_document(self, session: AsyncSession, user: str, collection_id
279280
except Exception as e:
280281
logger.warning(f"Failed to delete objects for document {document.id} from object store: {e}")
281282

282-
# Delete the document record from the database
283-
await session.delete(document)
283+
# Mark document as deleted
284+
document.status = db_models.DocumentStatus.DELETED
285+
document.gmt_deleted = utc_now()
286+
session.add(document)
284287
await session.flush()
285-
logger.info(f"Successfully marked document {document.id} and its indexes for deletion.")
288+
logger.info(f"Successfully marked document {document.id} as deleted.")
286289

287290
return document
288291

0 commit comments

Comments
 (0)