MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / archive_entry_bytes

Function archive_entry_bytes

xtask/src/main.rs:5756–5785  ·  view source on GitHub ↗
(archive_path: &Path, entry_name: &str)

Source from the content-addressed store, hash-verified

5754}
5755
5756fn archive_entry_bytes(archive_path: &Path, entry_name: &str) -> Result<Vec<u8>> {
5757 let file =
5758 fs::File::open(archive_path).with_context(|| format!("open {}", archive_path.display()))?;
5759 let decoder = zstd::stream::read::Decoder::new(file)
5760 .with_context(|| format!("create zstd decoder for {}", archive_path.display()))?;
5761 let mut archive = tar::Archive::new(decoder);
5762 for entry in archive
5763 .entries()
5764 .with_context(|| format!("read {}", archive_path.display()))?
5765 {
5766 let mut entry =
5767 entry.with_context(|| format!("read entry from {}", archive_path.display()))?;
5768 let path = entry
5769 .path()
5770 .with_context(|| format!("read path from {}", archive_path.display()))?
5771 .to_string_lossy()
5772 .trim_start_matches("./")
5773 .to_owned();
5774 if path == entry_name {
5775 let mut bytes = Vec::new();
5776 io::copy(&mut entry, &mut bytes)
5777 .with_context(|| format!("read {entry_name} from {}", archive_path.display()))?;
5778 return Ok(bytes);
5779 }
5780 }
5781 bail!(
5782 "{} is missing archive entry {entry_name}",
5783 archive_path.display()
5784 )
5785}
5786
5787fn check_no_committed_aot_artifacts() -> Result<()> {
5788 let tracked = command_output("git", &["ls-files", "crates/aot"], Path::new("."))?;

Callers 3

from_packaged_assetsMethod · 0.85

Calls 1

pathMethod · 0.45

Tested by

no test coverage detected