Skip to content

Commit e4196da

Browse files
authored
Merge pull request #98 from cgwalters/getblob-no-u64-raw
get_raw_blob: Properly handle -1 return from GetRawBlob
2 parents fdcc0a6 + a3f486d commit e4196da

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/imageproxy.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,20 +686,22 @@ impl ImageProxy {
686686

687687
/// Fetch a blob identified by e.g. `sha256:<digest>`; does not perform
688688
/// any verification that the blob matches the digest. The size of the
689-
/// blob and a pipe file descriptor are returned.
689+
/// blob (if available) and a pipe file descriptor are returned.
690690
#[instrument]
691691
pub async fn get_raw_blob(
692692
&self,
693693
img: &OpenedImage,
694694
digest: &Digest,
695695
) -> Result<(
696-
u64,
696+
Option<u64>,
697697
tokio::fs::File,
698698
impl Future<Output = std::result::Result<(), GetBlobError>> + Unpin + '_,
699699
)> {
700700
tracing::debug!("fetching blob");
701701
let args: Vec<serde_json::Value> = vec![img.0.into(), digest.to_string().into()];
702-
let (bloblen, fds): (u64, DualFds) = self.impl_request_with_fds("GetRawBlob", args).await?;
702+
let (bloblen, fds): (i64, DualFds) = self.impl_request_with_fds("GetRawBlob", args).await?;
703+
// See the GetBlob case, we have a best-effort attempt to return the size, but it might not be known
704+
let bloblen = u64::try_from(bloblen).ok();
703705
let fd = tokio::fs::File::from_std(std::fs::File::from(fds.datafd));
704706
let err = Self::read_blob_error(fds.errfd).boxed();
705707
Ok((bloblen, fd, err))

0 commit comments

Comments
 (0)