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

fix: allow not finding arch platforms in channel #164

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Changes from 1 commit
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
36 changes: 31 additions & 5 deletions src/render/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ use rattler_conda_types::{
Channel, ChannelConfig, GenericVirtualPackage, MatchSpec, Platform, PrefixRecord,
RepoDataRecord,
};
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::{LibsolvRepoData, SolverBackend, SolverTask};
use reqwest::Client;
use reqwest::{Client, StatusCode};
use std::{
borrow::Cow,
fmt::Write,
Expand Down Expand Up @@ -129,6 +131,7 @@ pub async fn create_environment(
&repodata_cache,
download_client.clone(),
multi_progress,
platform != Platform::NoArch,
)
.await
}
Expand All @@ -138,6 +141,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 @@ -478,7 +486,8 @@ async fn fetch_repo_data_records_with_progress(
repodata_cache: &Path,
client: Client,
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 @@ -507,8 +516,25 @@ 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) => {
let not_found = match &e {
FetchRepoDataError::HttpError(e) if e.status() == Some(StatusCode::NOT_FOUND) => {
true
}
FetchRepoDataError::FailedToDownloadRepoData(e)
if e.kind() == std::io::ErrorKind::NotFound =>
{
true
}
_ => false,
};
wolfv marked this conversation as resolved.
Show resolved Hide resolved

if not_found && 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 @@ -533,7 +559,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