From cf5d30c53f8f346c2f1e956a44732e789914479d Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Mon, 27 May 2024 13:57:44 +0200 Subject: [PATCH] pxar: bin: cover listing for split archives Allows to list entries of split pxar archives. As the decoder skips over the file payloads, the corresponding payload file has to be provided. Otherwise the decoder would skip inside the metadata archive, leading to incorrect decoding. Signed-off-by: Christian Ebner --- pxar-bin/src/main.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs index fe5c91c9..2657577d 100644 --- a/pxar-bin/src/main.rs +++ b/pxar-bin/src/main.rs @@ -454,12 +454,26 @@ async fn mount_archive(archive: String, mountpoint: String, verbose: bool) -> Re archive: { description: "Archive name.", }, + "payload-input": { + description: "'ppxar' payload input data file for split archive.", + optional: true, + }, }, }, )] /// List the contents of an archive. -fn dump_archive(archive: String) -> Result<(), Error> { - for entry in pxar::decoder::Decoder::open(pxar::PxarVariant::Unified(archive))? { +fn dump_archive(archive: String, payload_input: Option) -> Result<(), Error> { + if archive.ends_with(".mpxar") && payload_input.is_none() { + bail!("Payload input required for split pxar archives"); + } + + let input = if let Some(payload_input) = payload_input { + pxar::PxarVariant::Split(archive, payload_input) + } else { + pxar::PxarVariant::Unified(archive) + }; + + for entry in pxar::decoder::Decoder::open(input)? { let entry = entry?; if log::log_enabled!(log::Level::Debug) { @@ -502,7 +516,8 @@ fn main() { "list", CliCommand::new(&API_METHOD_DUMP_ARCHIVE) .arg_param(&["archive"]) - .completion_cb("archive", complete_file_name), + .completion_cb("archive", complete_file_name) + .completion_cb("payload-input", complete_file_name), ); let rpcenv = CliEnvironment::new();