pxar: typedef on_error as ErrorHandler

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-01-25 14:42:53 +01:00 committed by Wolfgang Bumiller
parent e43b9175c0
commit e97025ab02
3 changed files with 7 additions and 5 deletions

View File

@ -17,7 +17,7 @@ use proxmox::api::cli::*;
use proxmox::api::api;
use proxmox_backup::tools;
use proxmox_backup::pxar::{fuse, format_single_line_entry, ENCODER_MAX_ENTRIES, Flags};
use proxmox_backup::pxar::{fuse, format_single_line_entry, ENCODER_MAX_ENTRIES, ErrorHandler, Flags};
fn extract_archive_from_reader<R: std::io::Read>(
reader: &mut R,
@ -27,7 +27,7 @@ fn extract_archive_from_reader<R: std::io::Read>(
verbose: bool,
match_list: &[MatchEntry],
extract_match_default: bool,
on_error: Option<Box<dyn FnMut(Error) -> Result<(), Error> + Send>>,
on_error: Option<ErrorHandler>,
) -> Result<(), Error> {
proxmox_backup::pxar::extract_archive(
pxar::decoder::Decoder::from_std(reader)?,

View File

@ -24,6 +24,8 @@ use crate::pxar::dir_stack::PxarDirStack;
use crate::pxar::metadata;
use crate::pxar::Flags;
pub type ErrorHandler = Box<dyn FnMut(Error) -> Result<(), Error> + Send>;
pub fn extract_archive<T, F>(
mut decoder: pxar::decoder::Decoder<T>,
destination: &Path,
@ -32,7 +34,7 @@ pub fn extract_archive<T, F>(
feature_flags: Flags,
allow_existing_dirs: bool,
mut callback: F,
on_error: Option<Box<dyn FnMut(Error) -> Result<(), Error> + Send>>,
on_error: Option<ErrorHandler>,
) -> Result<(), Error>
where
T: pxar::decoder::SeqRead,
@ -212,7 +214,7 @@ pub(crate) struct Extractor {
/// Error callback. Includes `current_path` in the reformatted error, should return `Ok` to
/// continue extracting or the passed error as `Err` to bail out.
on_error: Box<dyn FnMut(Error) -> Result<(), Error> + Send>,
on_error: ErrorHandler,
}
impl Extractor {

View File

@ -59,7 +59,7 @@ mod flags;
pub use flags::Flags;
pub use create::create_archive;
pub use extract::extract_archive;
pub use extract::{extract_archive, ErrorHandler};
/// The format requires to build sorted directory lookup tables in
/// memory, so we restrict the number of allowed entries to limit