Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions aperag/service/document_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from aperag.schema.view_models import DocumentList
from aperag.utils.constant import QuotaType
from aperag.utils.uncompress import SUPPORTED_COMPRESSED_EXTENSIONS
from aperag.utils.utils import utc_now

logger = logging.getLogger(__name__)

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

# Delete the document record from the database
await session.delete(document)
# Mark document as deleted
document.status = db_models.DocumentStatus.DELETED
document.gmt_deleted = utc_now()
session.add(document)
await session.flush()
logger.info(f"Successfully marked document {document.id} and its indexes for deletion.")
logger.info(f"Successfully marked document {document.id} as deleted.")

return document

Expand Down
Loading