From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Filip Schauer <f.schauer@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn
Date: Thu, 22 Oct 2026 13:20:47 +0200 [thread overview]
Message-ID: <3xgxescry5erkm5xt5m6pt3oleljb5ifxrwfabsx6wwonnh46a@o6bidvabgyrr> (raw)
In-Reply-To: <20261013083039.27681-1-f.schauer@proxmox.com>
On Tue, Oct 13, 2026 at 10:30:37AM +0200, Filip Schauer wrote:
> zstd::Decoder::new cannot fail (see gyscos/zstd-rs#281), so simplify
I don't want to rely on something happening in a dependency's wrapped
library like that.
Let's just wait for `zstd` to drop the `Result` *or* at the very least
make the error case `Infallible`/`!`.
> DecodeFn to return Box<dyn Read> directly.
>
> Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
> ---
> proxmox-oci/src/lib.rs | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/proxmox-oci/src/lib.rs b/proxmox-oci/src/lib.rs
> index b274e46a..3b6dbeb0 100644
> --- a/proxmox-oci/src/lib.rs
> +++ b/proxmox-oci/src/lib.rs
> @@ -201,16 +201,17 @@ fn extract_image_rootfs<R: Read + Seek, P: AsRef<Path>>(
> .open_blob(layer_descriptor.digest())
> .ok_or(ExtractError::MissingLayerFile(layer_digest))?;
>
> - type DecodeFn<T> = Box<dyn for<'a> Fn(&'a mut T) -> io::Result<Box<dyn Read + 'a>>>;
> + type DecodeFn<T> = Box<dyn for<'a> Fn(&'a mut T) -> Box<dyn Read + 'a>>;
> let decode_fn: DecodeFn<OciTarImageBlob<R>> = match layer_descriptor.media_type() {
> MediaType::ImageLayer | MediaType::ImageLayerNonDistributable => {
> - Box::new(|file| Ok(Box::new(file)))
> + Box::new(|file| Box::new(file))
> }
> MediaType::ImageLayerGzip | MediaType::ImageLayerNonDistributableGzip => {
> - Box::new(|file| Ok(Box::new(GzDecoder::new(file))))
> + Box::new(|file| Box::new(GzDecoder::new(file)))
> }
> MediaType::ImageLayerZstd | MediaType::ImageLayerNonDistributableZstd => {
> - Box::new(|file| Ok(Box::new(zstd::Decoder::new(file)?)))
> + // https://github.com/gyscos/zstd-rs/issues/281
> + Box::new(|file| Box::new(zstd::Decoder::new(file).expect("infallible")))
> }
> // Error on any other non-ImageLayer related media types.
> // Match explicitly to avoid missing new image layer types when oci-spec updates.
> @@ -226,9 +227,9 @@ fn extract_image_rootfs<R: Read + Seek, P: AsRef<Path>>(
> }
> };
>
> - apply_whiteouts(&mut decode_fn(&mut layer_file)?, &target_path)?;
> + apply_whiteouts(&mut decode_fn(&mut layer_file), &target_path)?;
> layer_file.seek(SeekFrom::Start(0))?;
> - extract_archive(&mut decode_fn(&mut layer_file)?, &target_path)?;
> + extract_archive(&mut decode_fn(&mut layer_file), &target_path)?;
>
> oci_tar_image = layer_file.into_oci_tar_image();
> }
> --
> 2.47.3
prev parent reply other threads:[~2026-10-22 11:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 8:30 [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn Filip Schauer
2026-10-22 11:20 ` Wolfgang Bumiller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3xgxescry5erkm5xt5m6pt3oleljb5ifxrwfabsx6wwonnh46a@o6bidvabgyrr \
--to=w.bumiller@proxmox.com \
--cc=f.schauer@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox