async def _process_and_yield_file(
        self, file_entity: NotionFileEntity
    ) -> Optional[NotionFileEntity]:
        """Process a file entity by downloading it and setting local_path."""
        try:
            # Skip files that need refresh (expired URLs)
            if file_entity.needs_refresh():
                logger.warning(f"Skipping file {file_entity.name} - URL expired")
                return None

            # Skip external files (can't be downloaded)
            if file_entity.file_type == "external":
                logger.info(f"Skipping external file {file_entity.name} - external URL")
                return None

            # Download the file using BaseSource.process_file_entity
            if file_entity.file_type == "file_upload":
                # For file_upload type, we need special headers and access token
                headers = {"Notion-Version": "2022-06-28"}
                processed_entity = await self.process_file_entity(
                    file_entity=file_entity, access_token=self.access_token, headers=headers
                )
            else:  # file_type == "file"
                # For Notion-hosted files, use the temporary URL directly
                # Pre-signed URLs don't need authentication
                try:
                    # Try with access token first
                    processed_entity = await self.process_file_entity(
                        file_entity=file_entity, access_token=self.access_token
                    )
                except Exception:
                    # If that fails, try the custom pre-signed file processing
                    logger.info(f"Falling back to pre-signed URL processing for {file_entity.name}")
                    processed_entity = await self._process_presigned_file(file_entity)

            if processed_entity and not getattr(processed_entity, "should_skip", False):
                logger.info(
                    f"Successfully processed file {processed_entity.name} "
                    f"with local_path: {processed_entity.local_path}"
                )
                return processed_entity
            else:
                logger.warning(f"File {file_entity.name} was skipped during processing")
                return None

        except Exception as e:
            logger.error(f"Error processing file {file_entity.name}: {str(e)}")
            return None
Process a file entity by downloading it and setting local_path.
backend/airweave/platform/sources/notion.py