Skip to content

Commit 99efc0c

Browse files
allisonkarlitskayacgwalters
authored andcommitted
oci: workaround containers-image-proxy-rs #71
We can't read to the end of the stream without causing a deadlock, but fortunately the descriptor tells us how many bytes we're expecting. Use it to construct a `Take` stream which will return a synthetic EOF after exactly the correct number of bytes. Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 8eda2b0 commit 99efc0c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/oci/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use containers_image_proxy::{ImageProxy, ImageProxyConfig, OpenedImage};
1111
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
1212
use oci_spec::image::{Descriptor, ImageConfiguration, ImageManifest, MediaType};
1313
use sha2::{Digest, Sha256};
14+
use tokio::io::AsyncReadExt;
1415

1516
use crate::{
1617
fs::write_to_path,
@@ -106,6 +107,10 @@ impl<'repo> ImageOp<'repo> {
106107
} else {
107108
// Otherwise, we need to fetch it...
108109
let (blob_reader, driver) = self.proxy.get_descriptor(&self.img, descriptor).await?;
110+
111+
// See https://github.com/containers/containers-image-proxy-rs/issues/71
112+
let blob_reader = blob_reader.take(descriptor.size());
113+
109114
let bar = self.progress.add(ProgressBar::new(descriptor.size()));
110115
bar.set_style(ProgressStyle::with_template("[eta {eta}] {bar:40.cyan/blue} {decimal_bytes:>7}/{decimal_total_bytes:7} {msg}")
111116
.unwrap()

0 commit comments

Comments
 (0)