Repository: influxdata/influxdb
File: influxdb3_processing_engine/src/lib.rs (Rust)

Code before:
        rx.await.map_err(|e| {
            error!(%e, "error receiving response from plugin");
            ProcessingEngineError::RequestHandlerDown
        })
    }

    pub fn get_environment_manager(&self) -> Arc<dyn PythonEnvironmentManager> {
        Arc::clone(&self.environment_manager.package_manager)
    }

    pub async fn list_plugin_files(&self) -> Vec<PluginFileInfo> {
        let mut plugin_files = Vec::new();

        // Iterate through all triggers in every database
        for db_schema in self.catalog.list_db_schema() {
            for trigger in db_schema.processing_engine_triggers.resource_iter() {
                let plugin_name = Arc::<str>::clone(&trigger.trigger_name);
                debug!(
                    "Processing trigger '{}' with plugin_filename '{}'",
                    trigger.trigger_name, trigger.plugin_filename
                );

                if let Some(ref plugin_dir) = self.environment_manager.plugin_dir {
                    let plugin_path = plugin_dir.join(&trigger.plugin_filename);

                    if let Ok(metadata) = fs::metadata(&plugin_path)
                        && metadata.is_file()
                    {
                        plugin_files.push(PluginFileInfo {
                            plugin_name: Arc::<str>::clone(&plugin_name),
                            file_name: trigger.plugin_filename.clone().into(),
                            file_path: plugin_path.to_string_lossy().into(),
                            size_bytes: metadata.len() as i64,
                            last_modified_millis: metadata
                                .modified()
                                .ok()
                                .and_then(|t| t.duration_since(SystemTime::UNIX_EPOCH).ok())
                                .map(|d| d.as_millis() as i64)
                                .unwrap_or(0),
                        });
                    }
                }
            }
        }

        plugin_files
    }
}

#[async_trait::async_trait]
impl WalFileNotifier for ProcessingEngineManagerImpl {

Review comment (suggestion):
Would be good to use the `tokio` equivalent [`fs::metadata` function](https://docs.rs/tokio/latest/tokio/fs/fn.metadata.html) for `async` to not block IO.

Code after:
        rx.await.map_err(|e| {
            error!(%e, "error receiving response from plugin");
            ProcessingEngineError::RequestHandlerDown
        })
    }

    pub fn get_environment_manager(&self) -> Arc<dyn PythonEnvironmentManager> {
        Arc::clone(&self.environment_manager.package_manager)
    }

    pub async fn list_plugin_files(&self) -> Vec<PluginFileInfo> {
        let mut plugin_files = Vec::new();

        // Iterate through all triggers in every database
        for db_schema in self.catalog.list_db_schema() {
            for trigger in db_schema.processing_engine_triggers.resource_iter() {
                let plugin_name = Arc::<str>::clone(&trigger.trigger_name);
                debug!(
                    "Processing trigger '{}' with plugin_filename '{}'",
                    trigger.trigger_name, trigger.plugin_filename
                );

                if let Some(ref plugin_dir) = self.environment_manager.plugin_dir {
                    let plugin_path = plugin_dir.join(&trigger.plugin_filename);

                    if let Ok(metadata) = fs::metadata(&plugin_path).await
                        && metadata.is_file()
                    {
                        plugin_files.push(PluginFileInfo {
                            plugin_name: Arc::<str>::clone(&plugin_name),
                            file_name: trigger.plugin_filename.clone().into(),
                            file_path: plugin_path.to_string_lossy().into(),
                            size_bytes: metadata.len() as i64,
                            last_modified_millis: metadata
                                .modified()
                                .ok()
                                .and_then(|t| t.duration_since(SystemTime::UNIX_EPOCH).ok())
                                .map(|d| d.as_millis() as i64)
                                .unwrap_or(0),
                        });
                    }
                }
            }
        }

        plugin_files
    }
}

#[async_trait::async_trait]
impl WalFileNotifier for ProcessingEngineManagerImpl {