rename catar into pxar

To avoid confusion with the casync implementation.
This commit is contained in:
Dietmar Maurer
2019-03-14 10:54:09 +01:00
parent 7c4dd94670
commit 8968258b66
16 changed files with 85 additions and 82 deletions

View File

@ -11,22 +11,22 @@ use nix::fcntl::OFlag;
use nix::sys::stat::Mode;
use nix::dir::Dir;
use crate::catar::encoder::*;
use crate::pxar::encoder::*;
/// Stream implementation to encode and upload .catar archives.
/// Stream implementation to encode and upload .pxar archives.
///
/// The hyper client needs an async Stream for file upload, so we
/// spawn an extra thread to encode the .catar data and pipe it to the
/// spawn an extra thread to encode the .pxar data and pipe it to the
/// consumer.
///
/// Note: The currect implementation is not fully ansync and can block.
pub struct CaTarBackupStream {
pub struct PxarBackupStream {
pipe: Option<std::fs::File>,
buffer: Vec<u8>,
child: Option<thread::JoinHandle<()>>,
}
impl Drop for CaTarBackupStream {
impl Drop for PxarBackupStream {
fn drop(&mut self) {
drop(self.pipe.take());
@ -34,7 +34,7 @@ impl Drop for CaTarBackupStream {
}
}
impl CaTarBackupStream {
impl PxarBackupStream {
pub fn new(mut dir: Dir, path: PathBuf, all_file_systems: bool, verbose: bool) -> Result<Self, Error> {
let mut buffer = Vec::with_capacity(4096);
@ -44,8 +44,8 @@ impl CaTarBackupStream {
let child = thread::spawn(move|| {
let mut writer = unsafe { std::fs::File::from_raw_fd(tx) };
if let Err(err) = CaTarEncoder::encode(path, &mut dir, &mut writer, all_file_systems, verbose) {
eprintln!("catar encode failed - {}", err);
if let Err(err) = PxarEncoder::encode(path, &mut dir, &mut writer, all_file_systems, verbose) {
eprintln!("pxar encode failed - {}", err);
}
});
@ -63,7 +63,7 @@ impl CaTarBackupStream {
}
}
impl Stream for CaTarBackupStream {
impl Stream for PxarBackupStream {
type Item = Vec<u8>;
type Error = Error;

View File

@ -5,16 +5,16 @@ use std::os::unix::io::FromRawFd;
use std::path::{Path, PathBuf};
use std::io::Write;
use crate::catar::decoder::*;
use crate::pxar::decoder::*;
/// Writer implementation to deccode a .catar archive (download).
/// Writer implementation to deccode a .pxar archive (download).
pub struct CaTarBackupWriter {
pub struct PxarBackupWriter {
pipe: Option<std::fs::File>,
child: Option<thread::JoinHandle<()>>,
}
impl Drop for CaTarBackupWriter {
impl Drop for PxarBackupWriter {
fn drop(&mut self) {
drop(self.pipe.take());
@ -22,23 +22,23 @@ impl Drop for CaTarBackupWriter {
}
}
impl CaTarBackupWriter {
impl PxarBackupWriter {
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 base = PathBuf::from(base);
let child = thread::spawn(move|| {
let mut reader = unsafe { std::fs::File::from_raw_fd(rx) };
let mut decoder = CaTarDecoder::new(&mut reader);
let mut decoder = PxarDecoder::new(&mut reader);
if let Err(err) = decoder.restore(&base, & |path| {
println!("RESTORE: {:?}", path);
Ok(())
}) {
eprintln!("catar decode failed - {}", err);
eprintln!("pxar decode failed - {}", err);
}
});
@ -48,7 +48,7 @@ impl CaTarBackupWriter {
}
}
impl Write for CaTarBackupWriter {
impl Write for PxarBackupWriter {
fn write(&mut self, buffer: &[u8]) -> Result<usize, std::io::Error> {
let pipe = match self.pipe {