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:
committed by
Wolfgang Bumiller
parent
e97025ab02
commit
77486a608e
@ -283,23 +283,15 @@ async fn backup_directory<P: AsRef<Path>>(
|
||||
dir_path: P,
|
||||
archive_name: &str,
|
||||
chunk_size: Option<usize>,
|
||||
device_set: Option<HashSet<u64>>,
|
||||
verbose: bool,
|
||||
skip_lost_and_found: bool,
|
||||
catalog: Arc<Mutex<CatalogWriter<crate::tools::StdChannelWriter>>>,
|
||||
exclude_pattern: Vec<MatchEntry>,
|
||||
entries_max: usize,
|
||||
pxar_create_options: proxmox_backup::pxar::PxarCreateOptions,
|
||||
upload_options: UploadOptions,
|
||||
) -> Result<BackupStats, Error> {
|
||||
|
||||
let pxar_stream = PxarBackupStream::open(
|
||||
dir_path.as_ref(),
|
||||
device_set,
|
||||
verbose,
|
||||
skip_lost_and_found,
|
||||
catalog,
|
||||
exclude_pattern,
|
||||
entries_max,
|
||||
pxar_create_options,
|
||||
)?;
|
||||
let mut chunk_stream = ChunkStream::new(pxar_stream, chunk_size);
|
||||
|
||||
@ -1039,6 +1031,15 @@ async fn create_backup(
|
||||
|
||||
println!("Upload directory '{}' to '{}' as {}", filename, repo, target);
|
||||
catalog.lock().unwrap().start_directory(std::ffi::CString::new(target.as_str())?.as_c_str())?;
|
||||
|
||||
let pxar_options = proxmox_backup::pxar::PxarCreateOptions {
|
||||
device_set: devices.clone(),
|
||||
patterns: pattern_list.clone(),
|
||||
entries_max: entries_max as usize,
|
||||
skip_lost_and_found,
|
||||
verbose,
|
||||
};
|
||||
|
||||
let upload_options = UploadOptions {
|
||||
previous_manifest: previous_manifest.clone(),
|
||||
compress: true,
|
||||
@ -1051,12 +1052,8 @@ async fn create_backup(
|
||||
&filename,
|
||||
&target,
|
||||
chunk_size_opt,
|
||||
devices.clone(),
|
||||
verbose,
|
||||
skip_lost_and_found,
|
||||
catalog.clone(),
|
||||
pattern_list.clone(),
|
||||
entries_max as usize,
|
||||
pxar_options,
|
||||
upload_options,
|
||||
).await?;
|
||||
manifest.add_file(target, stats.size, stats.csum, crypt_mode)?;
|
||||
|
@ -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(())
|
||||
|
Reference in New Issue
Block a user