From 5defa71bf9e2013ffc992f7f957007ce1ebb20dc Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 15 Mar 2019 07:20:22 +0100 Subject: [PATCH] rename PxarBackupWriter into PxarDecodeWriter --- src/bin/proxmox-backup-client.rs | 2 +- src/client/pxar_decode_writer.rs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 5c9242eb..31d459d5 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -552,7 +552,7 @@ fn restore( println!("DOWNLOAD FILE {} to {}", path, target); let target = PathBuf::from(target); - let writer = PxarBackupWriter::new(&target, true)?; + let writer = PxarDecodeWriter::new(&target, true)?; client.download(&path, Box::new(writer))?; } else { bail!("unknown file extensions - unable to download '{}'", archive_name); diff --git a/src/client/pxar_decode_writer.rs b/src/client/pxar_decode_writer.rs index ec320bd3..b0700a31 100644 --- a/src/client/pxar_decode_writer.rs +++ b/src/client/pxar_decode_writer.rs @@ -9,12 +9,12 @@ use crate::pxar::decoder::*; /// Writer implementation to deccode a .pxar archive (download). -pub struct PxarBackupWriter { +pub struct PxarDecodeWriter { pipe: Option, child: Option>, } -impl Drop for PxarBackupWriter { +impl Drop for PxarDecodeWriter { fn drop(&mut self) { drop(self.pipe.take()); @@ -22,9 +22,9 @@ impl Drop for PxarBackupWriter { } } -impl PxarBackupWriter { +impl PxarDecodeWriter { - pub fn new(base: &Path, _verbose: bool) -> Result { + pub fn new(base: &Path, verbose: bool) -> Result { let (rx, tx) = nix::unistd::pipe()?; let base = PathBuf::from(base); @@ -32,10 +32,11 @@ impl PxarBackupWriter { let child = thread::spawn(move|| { let mut reader = unsafe { std::fs::File::from_raw_fd(rx) }; let mut decoder = PxarDecoder::new(&mut reader); - - + if let Err(err) = decoder.restore(&base, & |path| { - println!("RESTORE: {:?}", path); + if verbose { + println!("RESTORE: {:?}", path); + } Ok(()) }) { eprintln!("pxar decode failed - {}", err); @@ -48,7 +49,7 @@ impl PxarBackupWriter { } } -impl Write for PxarBackupWriter { +impl Write for PxarDecodeWriter { fn write(&mut self, buffer: &[u8]) -> Result { let pipe = match self.pipe {