fn dump_blob(
    ctx: Arc<BuildContext>,
    snapshot_idx: u32,
    blob_id: String,
    blob_storage: Option<BlobStorage>,
    upper_nodes: UpperNodes,
    nodes: &mut Vec<Node>,
    chunk_dict: Arc<dyn ChunkDict>,
) -> Result<BlobContext> {
    let mut blob_ctx = BlobContext::new(blob_id, blob_storage)?;
    blob_ctx.set_chunk_dict(chunk_dict);
    blob_ctx.set_chunk_size(ctx.chunk_size);
    blob_ctx.set_meta_info_enabled(true);

    // Since all layers are built concurrently, it is not possible to deduplicate
    // chunk between layers while ensuring reproducible build, so we only do
    // deduplication within layers here, and use chunk dict to deduplicate most
    // of chunks shared between layers.
    let mut chunk_cache = HashChunkDict::default();

    let mut blob = Blob::new();
    blob.dump(
        ctx.as_ref(),
        &mut blob_ctx,
        snapshot_idx,
        nodes,
        &mut chunk_cache,
    )?;
    blob.flush(&mut blob_ctx)?;

    // Put the regular files from upper snapshot into UpperNodes, to make the
    // final bootstrap of image refer to the modified files in upper snapshot,
    // not the files in lower snapshot.
    for node in nodes {
        if node.is_dir() {
            continue;
        }
        let mut upper_nodes = upper_nodes.write().unwrap();
        if let Some(info) = upper_nodes.get_mut(node.target()) {
            if info.snapshot_idx < snapshot_idx {
                *info = UpperNode {
                    snapshot_idx,
                    chunks: node.chunks.clone(),
                    digest: *node.inode.digest(),
                };
            }
        } else {
            upper_nodes.insert(
                node.target().clone(),
                UpperNode {
                    snapshot_idx,
                    chunks: node.chunks.clone(),
                    digest: *node.inode.digest(),
                },
            );
        }
    }

    Ok(blob_ctx)
}
// Dump blob for addition and modification files from upper nodes.
Dump blob for addition and modification files from upper nodes.
Dump blob for addition and modification files from upper nodes .
fn dump_blob(
    ctx: Arc<BuildContext>,
    snapshot_idx: u32,
    blob_id: String,
    blob_storage: Option<BlobStorage>,
    upper_nodes: UpperNodes,
    nodes: &mut Vec<Node>,
    chunk_dict: Arc<dyn ChunkDict>,
) -> Result<BlobContext> {
    let mut blob_ctx = BlobContext::new(blob_id, blob_storage)?;
    blob_ctx.set_chunk_dict(chunk_dict);
    blob_ctx.set_chunk_size(ctx.chunk_size);
    blob_ctx.set_meta_info_enabled(true);
    // Since all layers are built concurrently, it is not possible to deduplicate
    // chunk between layers while ensuring reproducible build, so we only do
    // deduplication within layers here, and use chunk dict to deduplicate most
    // of chunks shared between layers.
    let mut chunk_cache = HashChunkDict::default();
    let mut blob = Blob::new();
    blob.dump(
        ctx.as_ref(),
        &mut blob_ctx,
        snapshot_idx,
        nodes,
        &mut chunk_cache,
    )?;
    blob.flush(&mut blob_ctx)?;
    // Put the regular files from upper snapshot into UpperNodes, to make the
    // final bootstrap of image refer to the modified files in upper snapshot,
    // not the files in lower snapshot.
    for node in nodes {
        if node.is_dir() {
            continue;
        }
        let mut upper_nodes = upper_nodes.write().unwrap();
        if let Some(info) = upper_nodes.get_mut(node.target()) {
            if info.snapshot_idx < snapshot_idx {
                *info = UpperNode {
                    snapshot_idx,
                    chunks: node.chunks.clone(),
                    digest: *node.inode.digest(),
                };
            }
        } else {
            upper_nodes.insert(
                node.target().clone(),
                UpperNode {
                    snapshot_idx,
                    chunks: node.chunks.clone(),
                    digest: *node.inode.digest(),
                },
            );
        }
    }
    Ok(blob_ctx)
}
fn dump_blob ( ctx : Arc < BuildContext > , snapshot_idx : u32 , blob_id : String , blob_storage : Option < BlobStorage > , upper_nodes : UpperNodes , nodes : & mut Vec < Node > , chunk_dict : Arc < dyn ChunkDict > , ) -> Result < BlobContext > { let mut blob_ctx = BlobContext :: new ( blob_id , blob_storage ) ? ; blob_ctx . set_chunk_dict ( chunk_dict ) ; blob_ctx . set_chunk_size ( ctx . chunk_size ) ; blob_ctx . set_meta_info_enabled ( true ) ; // Since all layers are built concurrently, it is not possible to deduplicate // chunk between layers while ensuring reproducible build, so we only do // deduplication within layers here, and use chunk dict to deduplicate most // of chunks shared between layers. let mut chunk_cache = HashChunkDict :: default ( ) ; let mut blob = Blob :: new ( ) ; blob . dump ( ctx . as_ref ( ) , & mut blob_ctx , snapshot_idx , nodes , & mut chunk_cache , ) ? ; blob . flush ( & mut blob_ctx ) ? ; // Put the regular files from upper snapshot into UpperNodes, to make the // final bootstrap of image refer to the modified files in upper snapshot, // not the files in lower snapshot. for node in nodes { if node . is_dir ( ) { continue ; } let mut upper_nodes = upper_nodes . write ( ) . unwrap ( ) ; if let Some ( info ) = upper_nodes . get_mut ( node . target ( ) ) { if info . snapshot_idx < snapshot_idx { * info = UpperNode { snapshot_idx , chunks : node . chunks . clone ( ) , digest : * node . inode . digest ( ) , } ; } } else { upper_nodes . insert ( node . target ( ) . clone ( ) , UpperNode { snapshot_idx , chunks : node . chunks . clone ( ) , digest : * node . inode . digest ( ) , } , ) ; } } Ok ( blob_ctx ) }
Dump blob for addition and modification files from upper nodes.
Dump blob for addition and modification files from upper nodes .
ctx
Arc<BuildContext>
snapshot_idx
u32
blob_id
String
blob_storage
Option<BlobStorage>
upper_nodes
UpperNodes
nodes
&mut Vec<Node>
chunk_dict
Arc<dyn ChunkDict>
ctx
Arc<BuildContext>
snapshot_idx
u32
blob_id
String
blob_storage
Option<BlobStorage>
upper_nodes
UpperNodes
nodes
&mut Vec<Node>
chunk_dict
Arc<dyn ChunkDict>