@@ -274,7 +274,13 @@ impl PreparedImport {
274
274
) -> impl Iterator < Item = Result < ( & ManifestLayerState , & History ) > > {
275
275
// FIXME use .filter(|h| h.empty_layer.unwrap_or_default()) after https://github.com/containers/oci-spec-rs/pull/100 lands.
276
276
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) ;
278
284
self . all_layers ( )
279
285
. zip ( history)
280
286
. map ( |( s, h) | h. map ( |h| ( s, h) ) )
@@ -1486,7 +1492,9 @@ pub(crate) fn export_to_oci(
1486
1492
let mut new_manifest = srcinfo. manifest . clone ( ) ;
1487
1493
new_manifest. layers_mut ( ) . clear ( ) ;
1488
1494
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
+ }
1490
1498
new_config. rootfs_mut ( ) . diff_ids_mut ( ) . clear ( ) ;
1491
1499
1492
1500
let mut dest_oci = ocidir:: OciDir :: ensure ( dest_oci. try_clone ( ) ?) ?;
@@ -1538,17 +1546,14 @@ pub(crate) fn export_to_oci(
1538
1546
. get ( i)
1539
1547
. and_then ( |l| l. annotations ( ) . as_ref ( ) )
1540
1548
. 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 ( )
1545
1553
. and_then ( |h| h. comment ( ) . as_deref ( ) )
1546
1554
. unwrap_or_default ( ) ;
1547
1555
1548
- let previous_created = srcinfo
1549
- . configuration
1550
- . history ( )
1551
- . get ( i)
1556
+ let previous_created = history_entry
1552
1557
. and_then ( |h| h. created ( ) . as_deref ( ) )
1553
1558
. and_then ( bootc_utils:: try_deserialize_timestamp)
1554
1559
. unwrap_or_default ( ) ;
0 commit comments