diff --git a/src/connectors/service.py b/src/connectors/service.py index 373c24a1..a49ab3e4 100644 --- a/src/connectors/service.py +++ b/src/connectors/service.py @@ -46,7 +46,8 @@ class ConnectorService: result = await doc_service.process_file_common( file_path=tmp_file.name, file_hash=document.id, # Use connector document ID as hash - owner_user_id=owner_user_id + owner_user_id=owner_user_id, + original_filename=document.filename # Pass the original Google Doc title ) # If successfully indexed, update the indexed documents with connector metadata diff --git a/src/services/document_service.py b/src/services/document_service.py index 98928a01..fc56db3d 100644 --- a/src/services/document_service.py +++ b/src/services/document_service.py @@ -80,7 +80,7 @@ class DocumentService: def __init__(self, process_pool=None): self.process_pool = process_pool - async def process_file_common(self, file_path: str, file_hash: str = None, owner_user_id: str = None): + async def process_file_common(self, file_path: str, file_hash: str = None, owner_user_id: str = None, original_filename: str = None): """ Common processing logic for both upload and upload_path. 1. Optionally compute SHA256 hash if not provided. @@ -121,7 +121,7 @@ class DocumentService: for i, (chunk, vect) in enumerate(zip(slim_doc["chunks"], embeddings)): chunk_doc = { "document_id": file_hash, - "filename": slim_doc["filename"], + "filename": original_filename if original_filename else slim_doc["filename"], "mimetype": slim_doc["mimetype"], "page": chunk["page"], "text": chunk["text"],