pxar: factor out PxarCreateOptions

containing the CLI parameters that are mostly passed-through from the
client to our pxar archive creation wrapper in pxar::create

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler
2021-01-25 14:42:54 +01:00
committed by Wolfgang Bumiller
parent e97025ab02
commit 77486a608e
6 changed files with 61 additions and 56 deletions

View File

@ -311,16 +311,16 @@ fn create_archive(
exclude: Option<Vec<String>>,
entries_max: isize,
) -> Result<(), Error> {
let pattern_list = {
let patterns = {
let input = exclude.unwrap_or_else(Vec::new);
let mut pattern_list = Vec::with_capacity(input.len());
let mut patterns = Vec::with_capacity(input.len());
for entry in input {
pattern_list.push(
patterns.push(
MatchEntry::parse_pattern(entry, PatternFlag::PATH_NAME, MatchType::Exclude)
.map_err(|err| format_err!("error in exclude pattern: {}", err))?,
);
}
pattern_list
patterns
};
let device_set = if all_file_systems {
@ -329,6 +329,15 @@ fn create_archive(
Some(HashSet::new())
};
let options = proxmox_backup::pxar::PxarCreateOptions {
entries_max: entries_max as usize,
device_set,
patterns,
verbose,
skip_lost_and_found: false,
};
let source = PathBuf::from(source);
let dir = nix::dir::Dir::open(
@ -368,18 +377,15 @@ fn create_archive(
proxmox_backup::pxar::create_archive(
dir,
writer,
pattern_list,
feature_flags,
device_set,
false,
|path| {
if verbose {
println!("{:?}", path);
}
Ok(())
},
entries_max as usize,
None,
options,
)?;
Ok(())