diff --git a/src/lock_file/update.rs b/src/lock_file/update.rs index 7d6961f3b..625fb6f63 100644 --- a/src/lock_file/update.rs +++ b/src/lock_file/update.rs @@ -1148,7 +1148,7 @@ enum TaskResult { async fn spawn_solve_conda_environment_task( group: GroupedEnvironment<'_>, existing_repodata_records: Arc, - repodata_gateway: Arc, + repodata_gateway: Gateway, platform: Platform, concurrency_semaphore: Arc, client: reqwest::Client, diff --git a/src/project/mod.rs b/src/project/mod.rs index c848ef0f1..867e92082 100644 --- a/src/project/mod.rs +++ b/src/project/mod.rs @@ -104,7 +104,7 @@ pub struct Project { authenticated_client: ClientWithMiddleware, /// The repodata gateway to use for answering queries about repodata. /// This is wrapped in a `OnceLock` to allow for lazy initialization. - repodata_gateway: OnceLock>, + repodata_gateway: OnceLock, /// The manifest for the project pub(crate) manifest: Manifest, /// The cache that contains environment variables diff --git a/src/project/repodata.rs b/src/project/repodata.rs index 09dfd7406..e12dc38aa 100644 --- a/src/project/repodata.rs +++ b/src/project/repodata.rs @@ -1,22 +1,10 @@ -use crate::project::has_features::HasFeatures; -use crate::project::Environment; -use crate::{config, project::Project, repodata}; -use indexmap::IndexMap; -use rattler_conda_types::{Channel, Platform}; -use rattler_repodata_gateway::{sparse::SparseRepoData, ChannelConfig, Gateway, SourceConfig}; +use crate::{config, project::Project}; +use rattler_repodata_gateway::{ChannelConfig, Gateway, SourceConfig}; use std::path::PathBuf; -use std::sync::Arc; impl Project { - // TODO: Remove this function once everything is migrated to the new environment system. - pub async fn fetch_sparse_repodata( - &self, - ) -> miette::Result> { - self.default_environment().fetch_sparse_repodata().await - } - /// Returns the [`Gateway`] used by this project. - pub fn repodata_gateway(&self) -> &Arc { + pub fn repodata_gateway(&self) -> &Gateway { self.repodata_gateway.get_or_init(|| { // Determine the cache directory and fall back to sane defaults otherwise. let cache_dir = config::get_cache_dir().unwrap_or_else(|e| { @@ -38,32 +26,14 @@ impl Project { .unwrap_or_default(); // Construct the gateway - let gateway = Gateway::builder() + Gateway::builder() .with_client(self.authenticated_client().clone()) .with_cache_dir(cache_dir.join("repodata")) .with_channel_config(ChannelConfig { default: default_source_config, per_channel: Default::default(), }) - .finish(); - - Arc::new(gateway) + .finish() }) } } - -impl Environment<'_> { - pub async fn fetch_sparse_repodata( - &self, - ) -> miette::Result> { - let channels = self.channels(); - let platforms = self.platforms(); - repodata::fetch_sparse_repodata( - channels, - platforms, - self.project().authenticated_client(), - Some(self.project().config()), - ) - .await - } -}