Skip to content

Commit

Permalink
Merge pull request coreos#4895 from cgwalters/catch-no-pkgs
Browse files Browse the repository at this point in the history
container: Check that we found packages
  • Loading branch information
cgwalters authored Apr 2, 2024
2 parents 5d6ee39 + 38c8548 commit cce4cee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rust/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ pub fn container_encapsulate(args: Vec<String>) -> CxxResult<()> {
let mut lowest_change_time = None;
let mut highest_change_time = None;
let mut package_meta = HashMap::new();
if pkglist.n_children() == 0 {
return Err("Failed to find any packages".to_owned().into());
}
for pkg in pkglist.iter() {
let name = pkg.child_value(0);
let name = name.str().unwrap();
Expand All @@ -293,7 +296,7 @@ pub fn container_encapsulate(args: Vec<String>) -> CxxResult<()> {
package_meta.insert(nevra, pkgmeta);
}

// SAFETY: There must be at least one package.
// SAFETY: There must be at least one package; checked above.
let (lowest_change_name, lowest_change_time) =
lowest_change_time.expect("Failed to find any packages");
let highest_change_time = highest_change_time.expect("Failed to find any packages");
Expand Down

0 comments on commit cce4cee

Please sign in to comment.