Skip to content

Commit

Permalink
Skips artifacts that have incorrect metadata (#30)
Browse files Browse the repository at this point in the history
When `rip` tries to retrieve metadata for a version it can now use
multiple artifacts to get the metadata from in the case that it cannot
parse one of the metadata entries.

This should be fine because the metadata for a version should be the
same.

Improves this issue: #27
  • Loading branch information
tdejager authored Sep 29, 2023
1 parent 6a74fc4 commit 30a950a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions crates/rattler_installs_packages/src/package_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl PackageDb {
artifacts: &'a [I],
) -> miette::Result<(&'a ArtifactInfo, A::Metadata)> {
// Find all the artifacts that match the artifact we are looking for
let mut matching_artifacts = artifacts
let matching_artifacts = artifacts
.iter()
.map(|artifact_info| artifact_info.borrow())
.filter(|artifact_info| artifact_info.is::<A>());
Expand All @@ -143,7 +143,15 @@ impl PackageDb {
Ok(artifact) => {
// Apparently the artifact has been downloaded, but its metadata has not been
// cached yet. Lets store it there.
let (blob, metadata) = artifact.metadata()?;
let metadata = artifact.metadata();
let Ok((blob, metadata)) = metadata else {
tracing::warn!(
"Error reading metadata from artifact '{}' skipping",
artifact_info.filename
);
continue;
};

self.put_metadata_in_cache(artifact_info, &blob)?;
return Ok((artifact_info, metadata));
}
Expand All @@ -159,7 +167,7 @@ impl PackageDb {

// Get the information from the first artifact. We assume the metadata is consistent across
// all matching artifacts
if let Some(artifact_info) = matching_artifacts.next() {
for artifact_info in matching_artifacts {
// Retrieve the metadata instead of the entire wheel
// If the dist-info is available separately, we can use that instead
if artifact_info.dist_info_metadata.available {
Expand Down Expand Up @@ -187,7 +195,14 @@ impl PackageDb {
.clone(),
body,
)?;
let (blob, metadata) = artifact.metadata()?;
let metadata = artifact.metadata();
let Ok((blob, metadata)) = metadata else {
tracing::warn!(
"Error reading metadata from artifact '{}' skipping",
artifact_info.filename
);
continue;
};
self.put_metadata_in_cache(artifact_info, &blob)?;
return Ok((artifact_info, metadata));
}
Expand Down

0 comments on commit 30a950a

Please sign in to comment.