langflow_file_id init

This commit is contained in:
phact 2025-09-29 14:54:30 -04:00
parent 6612388586
commit 1abb74a8ac

View file

@ -72,6 +72,8 @@ class LangflowConnectorService:
document.mimetype or "application/octet-stream", document.mimetype or "application/octet-stream",
) )
langflow_file_id = None # Initialize to track if upload succeeded
try:
upload_result = await self.langflow_service.upload_user_file( upload_result = await self.langflow_service.upload_user_file(
file_tuple, jwt_token file_tuple, jwt_token
) )
@ -92,7 +94,6 @@ class LangflowConnectorService:
# Use the same tweaks pattern as LangflowFileService # Use the same tweaks pattern as LangflowFileService
tweaks = {} # Let Langflow handle the ingestion with default settings tweaks = {} # Let Langflow handle the ingestion with default settings
try:
ingestion_result = await self.langflow_service.run_ingestion_flow( ingestion_result = await self.langflow_service.run_ingestion_flow(
file_paths=[langflow_file_path], file_paths=[langflow_file_path],
jwt_token=jwt_token, jwt_token=jwt_token,
@ -126,6 +127,7 @@ class LangflowConnectorService:
error=str(e), error=str(e),
) )
# Try to clean up Langflow file if upload succeeded but processing failed # Try to clean up Langflow file if upload succeeded but processing failed
if langflow_file_id is not None:
try: try:
await self.langflow_service.delete_user_file(langflow_file_id) await self.langflow_service.delete_user_file(langflow_file_id)
logger.debug( logger.debug(