async def _generate_file_entities(
        self,
        client: httpx.AsyncClient,
        corpora: str,
        include_all_drives: bool,
        drive_id: Optional[str] = None,
        context: str = "",
    ) -> AsyncGenerator[ChunkEntity, None]:
        """Generate file entities from a file listing."""
        async for file_obj in self._list_files(
            client, corpora, include_all_drives, drive_id, context
        ):
            try:
                # Check if file should be included based on exclusion patterns
                if not await self._should_include_file(client, file_obj):
                    continue  # Skip this file

                # Get file entity (might be None for trashed files)
                file_entity = self._build_file_entity(file_obj)

                # Skip if the entity was None (likely a trashed file)
                if not file_entity:
                    continue

                # Process the entity if it has a download URL
                if file_entity.download_url:
                    processed_entity = await self.process_file_entity(
                        file_entity=file_entity, access_token=self.access_token
                    )
                    yield processed_entity
                else:
                    # This should never happen now that we return None for files without URLs
                    logger.warning(f"No download URL available for {file_entity.name}")
            except Exception as e:
                error_context = f"in drive {drive_id}" if drive_id else "in MY DRIVE"
                logger.error(
                    f"\nFailed to process file {file_obj.get('name', 'unknown')} "
                    f"{error_context}: {str(e)}\n"
                )
                raise
Generate file entities from a file listing.
backend/airweave/platform/sources/google_drive.py