From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 358191FF16C for ; Mon, 12 Aug 2024 12:31:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 196373058F; Mon, 12 Aug 2024 12:31:57 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Mon, 12 Aug 2024 12:31:32 +0200 Message-Id: <20240812103139.288854-4-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240812103139.288854-1-c.ebner@proxmox.com> References: <20240812103139.288854-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v3 proxmox-backup 03/10] client: tools: move pxar root entry helper to pxar submodule X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Move the `handle_root_with_optional_format_version_prelude` helper, purely related to handling the root entry for pxar format version 2 archives, to the more fitting pxar tools submodule. Signed-off-by: Christian Ebner --- changes since version 2: - not present in previous version pbs-client/src/pxar/extract.rs | 2 +- pbs-client/src/pxar/tools.rs | 36 ++++++++++++++++++++++++++++++++++ pbs-client/src/tools/mod.rs | 36 ---------------------------------- src/api2/tape/restore.rs | 2 +- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs index b1245c5fc..bea37ee10 100644 --- a/pbs-client/src/pxar/extract.rs +++ b/pbs-client/src/pxar/extract.rs @@ -29,8 +29,8 @@ use proxmox_compression::zip::{ZipEncoder, ZipEntry}; use crate::pxar::dir_stack::PxarDirStack; use crate::pxar::metadata; +use crate::pxar::tools::handle_root_with_optional_format_version_prelude; use crate::pxar::Flags; -use crate::tools::handle_root_with_optional_format_version_prelude; pub struct PxarExtractOptions<'a> { pub match_list: &'a [MatchEntry], diff --git a/pbs-client/src/pxar/tools.rs b/pbs-client/src/pxar/tools.rs index c444a8941..2f517022f 100644 --- a/pbs-client/src/pxar/tools.rs +++ b/pbs-client/src/pxar/tools.rs @@ -339,3 +339,39 @@ pub async fn pxar_metadata_catalog_lookup( Ok(entries) } + +/// Decode possible format version and prelude entries before getting the root directory +/// entry. +/// +/// Returns the root directory entry and, if present, the prelude entry +pub fn handle_root_with_optional_format_version_prelude( + decoder: &mut pxar::decoder::sync::Decoder, +) -> Result<(pxar::Entry, Option), Error> { + let first = decoder + .next() + .ok_or_else(|| format_err!("missing root entry"))??; + match first.kind() { + pxar::EntryKind::Directory => { + let version = pxar::format::FormatVersion::Version1; + log::debug!("pxar format version '{version:?}'"); + Ok((first, None)) + } + pxar::EntryKind::Version(version) => { + log::debug!("pxar format version '{version:?}'"); + let second = decoder + .next() + .ok_or_else(|| format_err!("missing root entry"))??; + match second.kind() { + pxar::EntryKind::Directory => Ok((second, None)), + pxar::EntryKind::Prelude(_prelude) => { + let third = decoder + .next() + .ok_or_else(|| format_err!("missing root entry"))??; + Ok((third, Some(second))) + } + _ => bail!("unexpected entry kind {:?}", second.kind()), + } + } + _ => bail!("unexpected entry kind {:?}", first.kind()), + } +} diff --git a/pbs-client/src/tools/mod.rs b/pbs-client/src/tools/mod.rs index 87e74de6e..28db6f348 100644 --- a/pbs-client/src/tools/mod.rs +++ b/pbs-client/src/tools/mod.rs @@ -596,42 +596,6 @@ pub fn has_pxar_filename_extension(name: &str, with_didx_extension: bool) -> boo } } -/// Decode possible format version and prelude entries before getting the root directory -/// entry. -/// -/// Returns the root directory entry and, if present, the prelude entry -pub fn handle_root_with_optional_format_version_prelude( - decoder: &mut pxar::decoder::sync::Decoder, -) -> Result<(pxar::Entry, Option), Error> { - let first = decoder - .next() - .ok_or_else(|| format_err!("missing root entry"))??; - match first.kind() { - pxar::EntryKind::Directory => { - let version = pxar::format::FormatVersion::Version1; - log::debug!("pxar format version '{version:?}'"); - Ok((first, None)) - } - pxar::EntryKind::Version(version) => { - log::debug!("pxar format version '{version:?}'"); - let second = decoder - .next() - .ok_or_else(|| format_err!("missing root entry"))??; - match second.kind() { - pxar::EntryKind::Directory => Ok((second, None)), - pxar::EntryKind::Prelude(_prelude) => { - let third = decoder - .next() - .ok_or_else(|| format_err!("missing root entry"))??; - Ok((third, Some(second))) - } - _ => bail!("unexpected entry kind {:?}", second.kind()), - } - } - _ => bail!("unexpected entry kind {:?}", first.kind()), - } -} - /// Raise the soft limit for open file handles to the hard limit /// /// Returns the values set before raising the limit as libc::rlimit64 diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index b28db6e39..f7481bacc 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -25,7 +25,7 @@ use pbs_api_types::{ PRIV_DATASTORE_MODIFY, PRIV_TAPE_READ, TAPE_RESTORE_NAMESPACE_SCHEMA, TAPE_RESTORE_SNAPSHOT_SCHEMA, UPID_SCHEMA, }; -use pbs_client::tools::handle_root_with_optional_format_version_prelude; +use pbs_client::pxar::tools::handle_root_with_optional_format_version_prelude; use pbs_config::CachedUserInfo; use pbs_datastore::dynamic_index::DynamicIndexReader; use pbs_datastore::fixed_index::FixedIndexReader; -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel