@@ -274,7 +274,13 @@ impl PreparedImport {
274274 ) -> impl Iterator < Item = Result < ( & ManifestLayerState , & History ) > > {
275275 // FIXME use .filter(|h| h.empty_layer.unwrap_or_default()) after https://github.com/containers/oci-spec-rs/pull/100 lands.
276276 let truncated = std:: iter:: once_with ( || Err ( anyhow:: anyhow!( "Truncated history" ) ) ) ;
277- let history = self . config . history ( ) . iter ( ) . map ( Ok ) . chain ( truncated) ;
277+ let history = self
278+ . config
279+ . history ( )
280+ . iter ( )
281+ . flatten ( )
282+ . map ( Ok )
283+ . chain ( truncated) ;
278284 self . all_layers ( )
279285 . zip ( history)
280286 . map ( |( s, h) | h. map ( |h| ( s, h) ) )
@@ -1486,7 +1492,9 @@ pub(crate) fn export_to_oci(
14861492 let mut new_manifest = srcinfo. manifest . clone ( ) ;
14871493 new_manifest. layers_mut ( ) . clear ( ) ;
14881494 let mut new_config = srcinfo. configuration . clone ( ) ;
1489- new_config. history_mut ( ) . clear ( ) ;
1495+ if let Some ( history) = new_config. history_mut ( ) {
1496+ history. clear ( ) ;
1497+ }
14901498 new_config. rootfs_mut ( ) . diff_ids_mut ( ) . clear ( ) ;
14911499
14921500 let mut dest_oci = ocidir:: OciDir :: ensure ( dest_oci. try_clone ( ) ?) ?;
@@ -1538,17 +1546,14 @@ pub(crate) fn export_to_oci(
15381546 . get ( i)
15391547 . and_then ( |l| l. annotations ( ) . as_ref ( ) )
15401548 . cloned ( ) ;
1541- let previous_description = srcinfo
1542- . configuration
1543- . history ( )
1544- . get ( i )
1549+ let history = srcinfo. configuration . history ( ) . as_ref ( ) ;
1550+ let history_entry = history . and_then ( |v| v . get ( i ) ) ;
1551+ let previous_description = history_entry
1552+ . clone ( )
15451553 . and_then ( |h| h. comment ( ) . as_deref ( ) )
15461554 . unwrap_or_default ( ) ;
15471555
1548- let previous_created = srcinfo
1549- . configuration
1550- . history ( )
1551- . get ( i)
1556+ let previous_created = history_entry
15521557 . and_then ( |h| h. created ( ) . as_deref ( ) )
15531558 . and_then ( bootc_utils:: try_deserialize_timestamp)
15541559 . unwrap_or_default ( ) ;
0 commit comments