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>)
| 265 | /// uncompressed digest (`diff_id`), gzip the bytes, and compute the gzipped |
| 266 | /// digest and size. |
| 267 | fn 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. |
| 288 | fn whiteout_path(path: &str) -> String { |
no test coverage detected