Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove unused fetch_sparse_repodata #1411

Merged
merged 2 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading