mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-04-29 13:35:34 +00:00
client: tools: move pxar root entry helper to pxar submodule
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 <c.ebner@proxmox.com>
This commit is contained in:
parent
113c04bc60
commit
3a6755363b
@ -29,8 +29,8 @@ use proxmox_compression::zip::{ZipEncoder, ZipEntry};
|
|||||||
|
|
||||||
use crate::pxar::dir_stack::PxarDirStack;
|
use crate::pxar::dir_stack::PxarDirStack;
|
||||||
use crate::pxar::metadata;
|
use crate::pxar::metadata;
|
||||||
|
use crate::pxar::tools::handle_root_with_optional_format_version_prelude;
|
||||||
use crate::pxar::Flags;
|
use crate::pxar::Flags;
|
||||||
use crate::tools::handle_root_with_optional_format_version_prelude;
|
|
||||||
|
|
||||||
pub struct PxarExtractOptions<'a> {
|
pub struct PxarExtractOptions<'a> {
|
||||||
pub match_list: &'a [MatchEntry],
|
pub match_list: &'a [MatchEntry],
|
||||||
|
@ -339,3 +339,39 @@ pub async fn pxar_metadata_catalog_lookup<T: Clone + ReadAt>(
|
|||||||
|
|
||||||
Ok(entries)
|
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()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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
|
/// Raise the soft limit for open file handles to the hard limit
|
||||||
///
|
///
|
||||||
/// Returns the values set before raising the limit as libc::rlimit64
|
/// Returns the values set before raising the limit as libc::rlimit64
|
||||||
|
@ -25,7 +25,7 @@ use pbs_api_types::{
|
|||||||
PRIV_DATASTORE_MODIFY, PRIV_TAPE_READ, TAPE_RESTORE_NAMESPACE_SCHEMA,
|
PRIV_DATASTORE_MODIFY, PRIV_TAPE_READ, TAPE_RESTORE_NAMESPACE_SCHEMA,
|
||||||
TAPE_RESTORE_SNAPSHOT_SCHEMA, UPID_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_config::CachedUserInfo;
|
||||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||||
|
Loading…
Reference in New Issue
Block a user