rename PxarBackupWriter into PxarDecodeWriter

This commit is contained in:
Dietmar Maurer 2019-03-15 07:20:22 +01:00
parent b005ed12d5
commit 5defa71bf9
2 changed files with 10 additions and 9 deletions

View File

@ -552,7 +552,7 @@ fn restore(
println!("DOWNLOAD FILE {} to {}", path, target); println!("DOWNLOAD FILE {} to {}", path, target);
let target = PathBuf::from(target); let target = PathBuf::from(target);
let writer = PxarBackupWriter::new(&target, true)?; let writer = PxarDecodeWriter::new(&target, true)?;
client.download(&path, Box::new(writer))?; client.download(&path, Box::new(writer))?;
} else { } else {
bail!("unknown file extensions - unable to download '{}'", archive_name); bail!("unknown file extensions - unable to download '{}'", archive_name);

View File

@ -9,12 +9,12 @@ use crate::pxar::decoder::*;
/// Writer implementation to deccode a .pxar archive (download). /// Writer implementation to deccode a .pxar archive (download).
pub struct PxarBackupWriter { pub struct PxarDecodeWriter {
pipe: Option<std::fs::File>, pipe: Option<std::fs::File>,
child: Option<thread::JoinHandle<()>>, child: Option<thread::JoinHandle<()>>,
} }
impl Drop for PxarBackupWriter { impl Drop for PxarDecodeWriter {
fn drop(&mut self) { fn drop(&mut self) {
drop(self.pipe.take()); drop(self.pipe.take());
@ -22,9 +22,9 @@ impl Drop for PxarBackupWriter {
} }
} }
impl PxarBackupWriter { impl PxarDecodeWriter {
pub fn new(base: &Path, _verbose: bool) -> Result<Self, Error> { pub fn new(base: &Path, verbose: bool) -> Result<Self, Error> {
let (rx, tx) = nix::unistd::pipe()?; let (rx, tx) = nix::unistd::pipe()?;
let base = PathBuf::from(base); let base = PathBuf::from(base);
@ -32,10 +32,11 @@ impl PxarBackupWriter {
let child = thread::spawn(move|| { let child = thread::spawn(move|| {
let mut reader = unsafe { std::fs::File::from_raw_fd(rx) }; let mut reader = unsafe { std::fs::File::from_raw_fd(rx) };
let mut decoder = PxarDecoder::new(&mut reader); let mut decoder = PxarDecoder::new(&mut reader);
if let Err(err) = decoder.restore(&base, & |path| { if let Err(err) = decoder.restore(&base, & |path| {
println!("RESTORE: {:?}", path); if verbose {
println!("RESTORE: {:?}", path);
}
Ok(()) Ok(())
}) { }) {
eprintln!("pxar decode failed - {}", err); 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<usize, std::io::Error> { fn write(&mut self, buffer: &[u8]) -> Result<usize, std::io::Error> {
let pipe = match self.pipe { let pipe = match self.pipe {