Skip to content

Commit

Permalink
refactor: Remove unused fetch_sparse_repodata (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-lacroix authored May 19, 2024
1 parent a85a251 commit 3bca78a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/lock_file/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ enum TaskResult {
async fn spawn_solve_conda_environment_task(
group: GroupedEnvironment<'_>,
existing_repodata_records: Arc<RepoDataRecordsByName>,
repodata_gateway: Arc<Gateway>,
repodata_gateway: Gateway,
platform: Platform,
concurrency_semaphore: Arc<Semaphore>,
client: reqwest::Client,
Expand Down
2 changes: 1 addition & 1 deletion src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Arc<Gateway>>,
repodata_gateway: OnceLock<Gateway>,
/// The manifest for the project
pub(crate) manifest: Manifest,
/// The cache that contains environment variables
Expand Down
40 changes: 5 additions & 35 deletions src/project/repodata.rs
Original file line number Diff line number Diff line change
@@ -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<IndexMap<(Channel, Platform), SparseRepoData>> {
self.default_environment().fetch_sparse_repodata().await
}

/// Returns the [`Gateway`] used by this project.
pub fn repodata_gateway(&self) -> &Arc<Gateway> {
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| {
Expand All @@ -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<IndexMap<(Channel, Platform), SparseRepoData>> {
let channels = self.channels();
let platforms = self.platforms();
repodata::fetch_sparse_repodata(
channels,
platforms,
self.project().authenticated_client(),
Some(self.project().config()),
)
.await
}
}

0 comments on commit 3bca78a

Please sign in to comment.