mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-08 20:25:19 +02:00
fix(connectors): refresh document from DB before updating type
- Query document from database to ensure it's attached to session - Prevents detached instance errors after process_file_in_background commits - Properly updates document_type and metadata with session management
This commit is contained in:
parent
b2b891e4d7
commit
8da58be9e0
1 changed files with 14 additions and 0 deletions
|
|
@ -408,6 +408,20 @@ async def _process_single_file(
|
|||
return 0, 1
|
||||
|
||||
if document and file_metadata:
|
||||
# Refresh document from database to ensure it's attached to session
|
||||
from app.db import Document
|
||||
from sqlalchemy import select
|
||||
|
||||
# Get fresh document from database
|
||||
result = await session.execute(
|
||||
select(Document).where(Document.id == document.id)
|
||||
)
|
||||
document = result.scalar_one_or_none()
|
||||
|
||||
if not document:
|
||||
logger.error(f"Could not find document {document.id} in database")
|
||||
return 0, 1
|
||||
|
||||
# Update document type to GOOGLE_DRIVE_CONNECTOR and add metadata
|
||||
original_type = document.document_type
|
||||
document.document_type = DocumentType.GOOGLE_DRIVE_CONNECTOR
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue