diff --git a/src/server/pull.rs b/src/server/pull.rs index c12ecec8..e56f1dfb 100644 --- a/src/server/pull.rs +++ b/src/server/pull.rs @@ -737,7 +737,10 @@ pub(crate) async fn pull_store(mut params: PullParameters) -> Result bool + Send>; + #[async_trait::async_trait] /// `SyncSource` is a trait that provides an interface for synchronizing data/information from a /// source. @@ -218,6 +220,7 @@ pub(crate) trait SyncSource: Send + Sync { async fn list_namespaces( &self, max_depth: &mut Option, + filter_callback: NamespaceFilter, ) -> Result, Error>; /// Lists groups within a specific namespace from the source. @@ -260,6 +263,7 @@ impl SyncSource for RemoteSource { async fn list_namespaces( &self, max_depth: &mut Option, + filter_callback: NamespaceFilter, ) -> Result, Error> { if self.ns.is_root() && max_depth.map_or(false, |depth| depth == 0) { return Ok(vec![self.ns.clone()]); @@ -307,6 +311,8 @@ impl SyncSource for RemoteSource { .map(|list_item| list_item.ns) .collect(); + let list = list.into_iter().filter(filter_callback).collect(); + Ok(list) } @@ -400,13 +406,18 @@ impl SyncSource for LocalSource { async fn list_namespaces( &self, max_depth: &mut Option, + filter_callback: NamespaceFilter, ) -> Result, Error> { - ListNamespacesRecursive::new_max_depth( + let list: Result, Error> = ListNamespacesRecursive::new_max_depth( self.store.clone(), self.ns.clone(), max_depth.unwrap_or(MAX_NAMESPACE_DEPTH), )? - .collect() + .collect(); + + let list = list?.into_iter().filter(filter_callback).collect(); + + Ok(list) } async fn list_groups(