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

Method download_provenance

atomic-remote/src/http/queries.rs:561–601  ·  view source on GitHub ↗

Download a provenance graph from the remote server. # Arguments `hash` - The base32-encoded hash of the provenance graph. # Returns The raw provenance graph bytes.

(&self, hash: &str)

Source from the content-addressed store, hash-verified

559 ///
560 /// The raw provenance graph bytes.
561 pub async fn download_provenance(&self, hash: &str) -> RemoteResult<Bytes> {
562 let url = format!("{}?provenance={}", self.base_url, hash);
563 debug!("GET provenance: {}", url);
564
565 let response = self
566 .client
567 .get(&url)
568 .send()
569 .await
570 .map_err(|e| RemoteError::connection_failed(&url, e))?;
571
572 crate::check_min_version_header(response.headers());
573 let status = response.status();
574
575 match status {
576 StatusCode::OK => {
577 let data = response
578 .bytes()
579 .await
580 .map_err(|e| RemoteError::connection_failed(&url, e))?;
581 debug!(
582 "Downloaded provenance graph {} ({} bytes)",
583 hash,
584 data.len()
585 );
586 Ok(data)
587 }
588 StatusCode::NOT_FOUND => Err(RemoteError::protocol(format!(
589 "Provenance graph not found: {}",
590 hash
591 ))),
592 StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
593 let msg = response.text().await.unwrap_or_default();
594 Err(RemoteError::auth_failed(&url, msg))
595 }
596 _ => {
597 let msg = response.text().await.unwrap_or_default();
598 Err(RemoteError::http(status.as_u16(), msg))
599 }
600 }
601 }
602}

Callers

nothing calls this directly

Calls 5

check_min_version_headerFunction · 0.85
textMethod · 0.80
getMethod · 0.65
statusMethod · 0.45
bytesMethod · 0.45

Tested by

no test coverage detected