pxar: log when skipping mount points

Clippy complains about the number of paramters we have for
create_archive and it really does need to be made somewhat
less awkward and more usable. For now we just log to stderr
as we previously did. Added todo-comments for this.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-11-09 12:41:31 +01:00
parent b783591fb5
commit 47208b4147

View File

@ -89,7 +89,21 @@ struct HardLinkInfo {
st_ino: u64, st_ino: u64,
} }
/// In case we want to collect them or redirect them we can just add this here: /// TODO: make a builder for the create_archive call for fewer parameters and add a method to add a
/// logger which does not write to stderr.
struct Logger;
impl std::io::Write for Logger {
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
std::io::stderr().write(data)
}
fn flush(&mut self) -> io::Result<()> {
std::io::stderr().flush()
}
}
/// And the error case.
struct ErrorReporter; struct ErrorReporter;
impl std::io::Write for ErrorReporter { impl std::io::Write for ErrorReporter {
@ -116,6 +130,7 @@ struct Archiver<'a, 'b> {
device_set: Option<HashSet<u64>>, device_set: Option<HashSet<u64>>,
hardlinks: HashMap<HardLinkInfo, (PathBuf, LinkOffset)>, hardlinks: HashMap<HardLinkInfo, (PathBuf, LinkOffset)>,
errors: ErrorReporter, errors: ErrorReporter,
logger: Logger,
file_copy_buffer: Vec<u8>, file_copy_buffer: Vec<u8>,
} }
@ -181,6 +196,7 @@ where
device_set, device_set,
hardlinks: HashMap::new(), hardlinks: HashMap::new(),
errors: ErrorReporter, errors: ErrorReporter,
logger: Logger,
file_copy_buffer: vec::undefined(4 * 1024 * 1024), file_copy_buffer: vec::undefined(4 * 1024 * 1024),
}; };
@ -632,6 +648,7 @@ impl<'a, 'b> Archiver<'a, 'b> {
} }
let result = if skip_contents { let result = if skip_contents {
writeln!(self.logger, "skipping mount point: {:?}", self.path)?;
Ok(()) Ok(())
} else { } else {
self.archive_dir_contents(&mut encoder, dir, false) self.archive_dir_contents(&mut encoder, dir, false)