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

Function layer_file

atomic-repository/tests/native_span_record.rs:68–89  ·  view source on GitHub ↗
(image: &std::path::Path, digest: &str, wanted: &str)

Source from the content-addressed store, hash-verified

66 use std::io::Read;
67
68 fn layer_file(image: &std::path::Path, digest: &str, wanted: &str) -> Vec<u8> {
69 let path = image
70 .join("blobs/sha256")
71 .join(digest.strip_prefix("sha256:").unwrap());
72 let file = std::fs::File::open(path).unwrap();
73 let mut archive = tar::Archive::new(flate2::read::GzDecoder::new(file));
74 for item in archive.entries().unwrap() {
75 let mut entry = item.unwrap();
76 if entry
77 .path()
78 .unwrap()
79 .to_string_lossy()
80 .trim_start_matches("./")
81 == wanted
82 {
83 let mut bytes = Vec::new();
84 entry.read_to_end(&mut bytes).unwrap();
85 return bytes;
86 }
87 }
88 panic!("{wanted} missing from OCI layer {digest}");
89 }
90 fn manifest(image: &std::path::Path, digest: &str) -> serde_json::Value {
91 let path = image
92 .join("blobs/sha256")

Callers

nothing calls this directly

Calls 4

openFunction · 0.85
entriesMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected