From: Filip Schauer <f.schauer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn
Date: Tue, 13 Oct 2026 10:30:37 +0200 [thread overview]
Message-ID: <20261013083039.27681-1-f.schauer@proxmox.com> (raw)
zstd::Decoder::new cannot fail (see gyscos/zstd-rs#281), so simplify
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
reply other threads:[~2026-10-13 8:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261013083039.27681-1-f.schauer@proxmox.com \
--to=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