public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn
@ 2026-10-13  8:30 Filip Schauer
  0 siblings, 0 replies; only message in thread
From: Filip Schauer @ 2026-10-13  8:30 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-13  8:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13  8:30 [PATCH proxmox] oci: drop unnecessary Result from layer decode_fn Filip Schauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal