pxar: typedef on_error as ErrorHandler
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
e43b9175c0
commit
e97025ab02
@ -17,7 +17,7 @@ use proxmox::api::cli::*;
|
|||||||
use proxmox::api::api;
|
use proxmox::api::api;
|
||||||
|
|
||||||
use proxmox_backup::tools;
|
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>(
|
fn extract_archive_from_reader<R: std::io::Read>(
|
||||||
reader: &mut R,
|
reader: &mut R,
|
||||||
@ -27,7 +27,7 @@ fn extract_archive_from_reader<R: std::io::Read>(
|
|||||||
verbose: bool,
|
verbose: bool,
|
||||||
match_list: &[MatchEntry],
|
match_list: &[MatchEntry],
|
||||||
extract_match_default: bool,
|
extract_match_default: bool,
|
||||||
on_error: Option<Box<dyn FnMut(Error) -> Result<(), Error> + Send>>,
|
on_error: Option<ErrorHandler>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
proxmox_backup::pxar::extract_archive(
|
proxmox_backup::pxar::extract_archive(
|
||||||
pxar::decoder::Decoder::from_std(reader)?,
|
pxar::decoder::Decoder::from_std(reader)?,
|
||||||
|
@ -24,6 +24,8 @@ use crate::pxar::dir_stack::PxarDirStack;
|
|||||||
use crate::pxar::metadata;
|
use crate::pxar::metadata;
|
||||||
use crate::pxar::Flags;
|
use crate::pxar::Flags;
|
||||||
|
|
||||||
|
pub type ErrorHandler = Box<dyn FnMut(Error) -> Result<(), Error> + Send>;
|
||||||
|
|
||||||
pub fn extract_archive<T, F>(
|
pub fn extract_archive<T, F>(
|
||||||
mut decoder: pxar::decoder::Decoder<T>,
|
mut decoder: pxar::decoder::Decoder<T>,
|
||||||
destination: &Path,
|
destination: &Path,
|
||||||
@ -32,7 +34,7 @@ pub fn extract_archive<T, F>(
|
|||||||
feature_flags: Flags,
|
feature_flags: Flags,
|
||||||
allow_existing_dirs: bool,
|
allow_existing_dirs: bool,
|
||||||
mut callback: F,
|
mut callback: F,
|
||||||
on_error: Option<Box<dyn FnMut(Error) -> Result<(), Error> + Send>>,
|
on_error: Option<ErrorHandler>,
|
||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
where
|
where
|
||||||
T: pxar::decoder::SeqRead,
|
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
|
/// Error callback. Includes `current_path` in the reformatted error, should return `Ok` to
|
||||||
/// continue extracting or the passed error as `Err` to bail out.
|
/// 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 {
|
impl Extractor {
|
||||||
|
@ -59,7 +59,7 @@ mod flags;
|
|||||||
pub use flags::Flags;
|
pub use flags::Flags;
|
||||||
|
|
||||||
pub use create::create_archive;
|
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
|
/// The format requires to build sorted directory lookup tables in
|
||||||
/// memory, so we restrict the number of allowed entries to limit
|
/// memory, so we restrict the number of allowed entries to limit
|
||||||
|
Loading…
Reference in New Issue
Block a user