MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / finish_layer

Function finish_layer

atomic-repository/src/oci.rs:267–285  ·  view source on GitHub ↗

Finalize an uncompressed tar buffer into an [`OciLayer`]: compute the uncompressed digest (`diff_id`), gzip the bytes, and compute the gzipped digest and size.

(tar_buf: Vec<u8>)

Source from the content-addressed store, hash-verified

265/// uncompressed digest (`diff_id`), gzip the bytes, and compute the gzipped
266/// digest and size.
267fn finish_layer(tar_buf: Vec<u8>) -> std::io::Result<OciLayer> {
268 let diff_id = format!("sha256:{}", sha256_hex(&tar_buf));
269
270 let mut tar_gz = Vec::new();
271 {
272 let mut encoder = GzEncoder::new(&mut tar_gz, Compression::default());
273 encoder.write_all(&tar_buf)?;
274 encoder.finish()?;
275 }
276
277 let digest = format!("sha256:{}", sha256_hex(&tar_gz));
278 let size = tar_gz.len() as u64;
279 Ok(OciLayer {
280 tar_gz,
281 diff_id,
282 digest,
283 size,
284 })
285}
286
287/// Encode the OCI whiteout entry name for a deleted path.
288fn whiteout_path(path: &str) -> String {

Callers 2

layer_from_dirFunction · 0.85
layer_from_entriesFunction · 0.85

Calls 2

finishMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected