Skip to content

Commit

Permalink
fix: allow not finding arch platforms in channel (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-arts authored Jul 10, 2023
1 parent 45f3092 commit 144ada4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rattler_networking = { git = "https://github.com/mamba-org/rattler", branch = "m
# rattler_solve = { path = "../rattler/crates/rattler_solve" }
# rattler_shell = { path = "../rattler/crates/rattler_shell" }
# rattler_virtual_packages = { path = "../rattler/crates/rattler_virtual_packages" }

# rattler_networking = { path = "../rattler/crates/rattler_networking" }
anyhow = "1.0.71"
walkdir = "2.3.3"
sha2 = "0.10.6"
Expand Down
22 changes: 18 additions & 4 deletions src/render/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use rattler_conda_types::{
RepoDataRecord,
};
use rattler_networking::{AuthenticatedClient, AuthenticationStorage};
use rattler_repodata_gateway::fetch::{CacheResult, DownloadProgress, FetchRepoDataOptions};
use rattler_repodata_gateway::fetch::{
CacheResult, DownloadProgress, FetchRepoDataError, FetchRepoDataOptions,
};
use rattler_repodata_gateway::sparse::SparseRepoData;
use rattler_solve::{libsolv_c::Solver, SolverImpl, SolverTask};
use reqwest::Client;
Expand Down Expand Up @@ -133,6 +135,7 @@ pub async fn create_environment(
&repodata_cache,
download_client.clone(),
multi_progress,
platform != Platform::NoArch,
)
.await
}
Expand All @@ -142,6 +145,11 @@ pub async fn create_environment(
.await
// Collect into another iterator where we extract the first erroneous result
.into_iter()
.filter_map(|res| match res {
Ok(Some(data)) => Some(Ok(data)), // If Ok contains Some, keep the data
Ok(None) => None, // If Ok contains None, discard it
Err(e) => Some(Err(e)), // If Err, keep it as is
})
.collect::<Result<Vec<_>, _>>()?;

// Get the package names from the matchspecs so we can only load the package records that we need.
Expand Down Expand Up @@ -479,7 +487,8 @@ async fn fetch_repo_data_records_with_progress(
repodata_cache: &Path,
client: AuthenticatedClient,
multi_progress: indicatif::MultiProgress,
) -> Result<SparseRepoData, anyhow::Error> {
allow_not_found: bool,
) -> anyhow::Result<Option<SparseRepoData>> {
// Create a progress bar
let progress_bar = multi_progress.add(
indicatif::ProgressBar::new(1)
Expand Down Expand Up @@ -508,8 +517,13 @@ async fn fetch_repo_data_records_with_progress(
// Error out if an error occurred, but also update the progress bar
let result = match result {
Err(e) => {
if matches!(e, FetchRepoDataError::NotFound(_)) && allow_not_found {
progress_bar.set_style(errored_progress_style());
progress_bar.finish_with_message("Not Found");
return Ok(None);
}
progress_bar.set_style(errored_progress_style());
progress_bar.finish_with_message("Error");
progress_bar.finish_with_message("404 not found");
return Err(e.into());
}
Ok(result) => result,
Expand All @@ -534,7 +548,7 @@ async fn fetch_repo_data_records_with_progress(
CacheResult::CacheHit | CacheResult::CacheHitAfterFetch
);
progress_bar.finish_with_message(if is_cache_hit { "Using cache" } else { "Done" });
Ok(repodata)
Ok(Some(repodata))
}
Ok(Err(err)) => {
progress_bar.set_style(errored_progress_style());
Expand Down

0 comments on commit 144ada4

Please sign in to comment.