public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v4 proxmox-backup 03/10] client: tools: move pxar root entry helper to pxar module
Date: Mon, 21 Oct 2024 17:47:37 +0200	[thread overview]
Message-ID: <20241021154744.325556-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20241021154744.325556-1-c.ebner@proxmox.com>

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.

This is for code cleanup purposes only.

No functional changes.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 3:
- s/submodule/module
- Reword commit message in order to clarify intend of this and
  subsequent patches
- Add missing git trailers

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<T: Clone + ReadAt>(
 
     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<R: pxar::decoder::SeqRead>(
+    decoder: &mut pxar::decoder::sync::Decoder<R>,
+) -> Result<(pxar::Entry, Option<pxar::Entry>), 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<R: pxar::decoder::SeqRead>(
-    decoder: &mut pxar::decoder::sync::Decoder<R>,
-) -> Result<(pxar::Entry, Option<pxar::Entry>), 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.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

  parent reply	other threads:[~2024-10-21 15:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 15:47 [pbs-devel] [PATCH v4 proxmox-backup 00/10] fix catalog dump and shell for split pxar archives Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 01/10] client: tools: make tools module public Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 02/10] client: pxar: move catalog lookup helper to pxar tools Christian Ebner
2024-10-21 15:47 ` Christian Ebner [this message]
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 04/10] client: make helper to get remote pxar reader reusable Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 05/10] client: tools: factor out entry path prefix helper Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 06/10] client: tools: factor out pxar entry to dir entry mapping Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 07/10] client: add helper to dump catalog from metadata archive Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 08/10] client: catalog: fallback to metadata archives for catalog dump Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 09/10] client: helper to mimic catalog find using metadata archive Christian Ebner
2024-10-21 15:47 ` [pbs-devel] [PATCH v4 proxmox-backup 10/10] client: catalog shell: fallback to accessor for navigation Christian Ebner
2024-10-23 14:13 ` [pbs-devel] applied: [PATCH v4 proxmox-backup 00/10] fix catalog dump and shell for split pxar archives Fabian Grünbichler
2024-10-23 18:37   ` Christian Ebner
2024-10-24  7:44     ` Fabian Grünbichler

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=20241021154744.325556-4-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal