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

Function read_layer_entries

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

Read all entries (path, bytes) from a gzipped tar layer.

(tar_gz: &[u8])

Source from the content-addressed store, hash-verified

328
329 /// Read all entries (path, bytes) from a gzipped tar layer.
330 fn read_layer_entries(tar_gz: &[u8]) -> Vec<(String, Vec<u8>)> {
331 let decoder = flate2::read::GzDecoder::new(tar_gz);
332 let mut archive = tar::Archive::new(decoder);
333 let mut out = Vec::new();
334 for entry in archive.entries().unwrap() {
335 let mut entry = entry.unwrap();
336 let path = entry.path().unwrap().to_string_lossy().into_owned();
337 let mut bytes = Vec::new();
338 entry.read_to_end(&mut bytes).unwrap();
339 out.push((path, bytes));
340 }
341 out
342 }
343
344 #[test]
345 fn layer_from_dir_produces_valid_gzipped_tar() {

Calls 4

entriesMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45
pushMethod · 0.45