rename catar into pxar
To avoid confusion with the casync implementation.
This commit is contained in:
parent
7c4dd94670
commit
8968258b66
@ -17,7 +17,7 @@ use crate::config::datastore;
|
|||||||
|
|
||||||
use crate::backup::*;
|
use crate::backup::*;
|
||||||
|
|
||||||
mod catar;
|
mod pxar;
|
||||||
mod upload;
|
mod upload;
|
||||||
|
|
||||||
fn group_backups(backup_list: Vec<BackupInfo>) -> HashMap<String, Vec<BackupInfo>> {
|
fn group_backups(backup_list: Vec<BackupInfo>) -> HashMap<String, Vec<BackupInfo>> {
|
||||||
@ -380,7 +380,7 @@ pub fn router() -> Router {
|
|||||||
.get(ApiMethod::new(
|
.get(ApiMethod::new(
|
||||||
|_,_,_| Ok(json!([
|
|_,_,_| Ok(json!([
|
||||||
{"subdir": "backups" },
|
{"subdir": "backups" },
|
||||||
{"subdir": "catar" },
|
{"subdir": "pxar" },
|
||||||
{"subdir": "gc" },
|
{"subdir": "gc" },
|
||||||
{"subdir": "groups" },
|
{"subdir": "groups" },
|
||||||
{"subdir": "snapshots" },
|
{"subdir": "snapshots" },
|
||||||
@ -398,10 +398,10 @@ pub fn router() -> Router {
|
|||||||
ObjectSchema::new("List backups.")
|
ObjectSchema::new("List backups.")
|
||||||
.required("store", store_schema.clone()))))
|
.required("store", store_schema.clone()))))
|
||||||
.subdir(
|
.subdir(
|
||||||
"catar",
|
"pxar",
|
||||||
Router::new()
|
Router::new()
|
||||||
.download(catar::api_method_download_catar())
|
.download(pxar::api_method_download_pxar())
|
||||||
.upload(catar::api_method_upload_catar()))
|
.upload(pxar::api_method_upload_pxar()))
|
||||||
.subdir(
|
.subdir(
|
||||||
"test-upload",
|
"test-upload",
|
||||||
Router::new()
|
Router::new()
|
||||||
|
@ -18,13 +18,13 @@ use std::sync::Arc;
|
|||||||
use hyper::Body;
|
use hyper::Body;
|
||||||
use hyper::http::request::Parts;
|
use hyper::http::request::Parts;
|
||||||
|
|
||||||
pub struct UploadCaTar {
|
pub struct UploadPxar {
|
||||||
stream: Body,
|
stream: Body,
|
||||||
index: DynamicIndexWriter,
|
index: DynamicIndexWriter,
|
||||||
count: usize,
|
count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Future for UploadCaTar {
|
impl Future for UploadPxar {
|
||||||
type Item = ();
|
type Item = ();
|
||||||
type Error = failure::Error;
|
type Error = failure::Error;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ impl Future for UploadCaTar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upload_catar(
|
fn upload_pxar(
|
||||||
parts: Parts,
|
parts: Parts,
|
||||||
req_body: Body,
|
req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
@ -57,8 +57,8 @@ fn upload_catar(
|
|||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
let mut archive_name = String::from(tools::required_string_param(¶m, "archive-name")?);
|
let mut archive_name = String::from(tools::required_string_param(¶m, "archive-name")?);
|
||||||
|
|
||||||
if !archive_name.ends_with(".catar") {
|
if !archive_name.ends_with(".pxar") {
|
||||||
bail!("got wront file extension (expected '.catar')");
|
bail!("got wront file extension (expected '.pxar')");
|
||||||
}
|
}
|
||||||
|
|
||||||
archive_name.push_str(".didx");
|
archive_name.push_str(".didx");
|
||||||
@ -72,8 +72,8 @@ fn upload_catar(
|
|||||||
let content_type = parts.headers.get(http::header::CONTENT_TYPE)
|
let content_type = parts.headers.get(http::header::CONTENT_TYPE)
|
||||||
.ok_or(format_err!("missing content-type header"))?;
|
.ok_or(format_err!("missing content-type header"))?;
|
||||||
|
|
||||||
if content_type != "application/x-proxmox-backup-catar" {
|
if content_type != "application/x-proxmox-backup-pxar" {
|
||||||
bail!("got wrong content-type for catar archive upload");
|
bail!("got wrong content-type for pxar archive upload");
|
||||||
}
|
}
|
||||||
|
|
||||||
let chunk_size = param["chunk-size"].as_u64().unwrap_or(4096*1024);
|
let chunk_size = param["chunk-size"].as_u64().unwrap_or(4096*1024);
|
||||||
@ -88,7 +88,7 @@ fn upload_catar(
|
|||||||
|
|
||||||
let index = datastore.create_dynamic_writer(path, chunk_size as usize)?;
|
let index = datastore.create_dynamic_writer(path, chunk_size as usize)?;
|
||||||
|
|
||||||
let upload = UploadCaTar { stream: req_body, index, count: 0};
|
let upload = UploadPxar { stream: req_body, index, count: 0};
|
||||||
|
|
||||||
let resp = upload.and_then(|_| {
|
let resp = upload.and_then(|_| {
|
||||||
|
|
||||||
@ -103,10 +103,10 @@ fn upload_catar(
|
|||||||
Ok(Box::new(resp))
|
Ok(Box::new(resp))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn api_method_upload_catar() -> ApiAsyncMethod {
|
pub fn api_method_upload_pxar() -> ApiAsyncMethod {
|
||||||
ApiAsyncMethod::new(
|
ApiAsyncMethod::new(
|
||||||
upload_catar,
|
upload_pxar,
|
||||||
ObjectSchema::new("Upload .catar backup file.")
|
ObjectSchema::new("Upload .pxar backup file.")
|
||||||
.required("store", StringSchema::new("Datastore name."))
|
.required("store", StringSchema::new("Datastore name."))
|
||||||
.required("archive-name", StringSchema::new("Backup archive name."))
|
.required("archive-name", StringSchema::new("Backup archive name."))
|
||||||
.required("backup-type", StringSchema::new("Backup type.")
|
.required("backup-type", StringSchema::new("Backup type.")
|
||||||
@ -124,7 +124,7 @@ pub fn api_method_upload_catar() -> ApiAsyncMethod {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn download_catar(
|
fn download_pxar(
|
||||||
_parts: Parts,
|
_parts: Parts,
|
||||||
_req_body: Body,
|
_req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
@ -135,7 +135,7 @@ fn download_catar(
|
|||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
let mut archive_name = tools::required_string_param(¶m, "archive-name")?.to_owned();
|
let mut archive_name = tools::required_string_param(¶m, "archive-name")?.to_owned();
|
||||||
|
|
||||||
if !archive_name.ends_with(".catar") {
|
if !archive_name.ends_with(".pxar") {
|
||||||
bail!("wrong archive extension");
|
bail!("wrong archive extension");
|
||||||
} else {
|
} else {
|
||||||
archive_name.push_str(".didx");
|
archive_name.push_str(".didx");
|
||||||
@ -167,10 +167,10 @@ fn download_catar(
|
|||||||
Ok(Box::new(future::ok(response)))
|
Ok(Box::new(future::ok(response)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn api_method_download_catar() -> ApiAsyncMethod {
|
pub fn api_method_download_pxar() -> ApiAsyncMethod {
|
||||||
ApiAsyncMethod::new(
|
ApiAsyncMethod::new(
|
||||||
download_catar,
|
download_pxar,
|
||||||
ObjectSchema::new("Download .catar backup file.")
|
ObjectSchema::new("Download .pxar backup file.")
|
||||||
.required("store", StringSchema::new("Datastore name."))
|
.required("store", StringSchema::new("Datastore name."))
|
||||||
.required("archive-name", StringSchema::new("Backup archive name."))
|
.required("archive-name", StringSchema::new("Backup archive name."))
|
||||||
.required("backup-type", StringSchema::new("Backup type.")
|
.required("backup-type", StringSchema::new("Backup type.")
|
@ -24,7 +24,7 @@ type Result<T> = std::result::Result<T, Error>;
|
|||||||
pub fn api_method_upgrade_upload() -> ApiAsyncMethod {
|
pub fn api_method_upgrade_upload() -> ApiAsyncMethod {
|
||||||
ApiAsyncMethod::new(
|
ApiAsyncMethod::new(
|
||||||
upgrade_upload,
|
upgrade_upload,
|
||||||
ObjectSchema::new("Download .catar backup file.")
|
ObjectSchema::new("Download .pxar backup file.")
|
||||||
.required("store", StringSchema::new("Datastore name.")),
|
.required("store", StringSchema::new("Datastore name.")),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ impl DynamicIndexReader {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump_catar(&self, mut writer: Box<Write>) -> Result<(), Error> {
|
pub fn dump_pxar(&self, mut writer: Box<Write>) -> Result<(), Error> {
|
||||||
|
|
||||||
let mut buffer = Vec::with_capacity(1024*1024);
|
let mut buffer = Vec::with_capacity(1024*1024);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use proxmox_backup::client::*;
|
|||||||
use proxmox_backup::backup::*;
|
use proxmox_backup::backup::*;
|
||||||
//use proxmox_backup::backup::image_index::*;
|
//use proxmox_backup::backup::image_index::*;
|
||||||
//use proxmox_backup::config::datastore;
|
//use proxmox_backup::config::datastore;
|
||||||
//use proxmox_backup::catar::encoder::*;
|
//use proxmox_backup::pxar::encoder::*;
|
||||||
//use proxmox_backup::backup::datastore::*;
|
//use proxmox_backup::backup::datastore::*;
|
||||||
|
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
@ -26,7 +26,7 @@ use xdg::BaseDirectories;
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref BACKUPSPEC_REGEX: Regex = Regex::new(r"^([a-zA-Z0-9_-]+\.(?:catar|raw)):(.+)$").unwrap();
|
static ref BACKUPSPEC_REGEX: Regex = Regex::new(r"^([a-zA-Z0-9_-]+\.(?:pxar|raw)):(.+)$").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,13 +129,13 @@ fn backup_directory<P: AsRef<Path>>(
|
|||||||
|
|
||||||
let query = tools::json_object_to_query(param)?;
|
let query = tools::json_object_to_query(param)?;
|
||||||
|
|
||||||
let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store(), query);
|
let path = format!("api2/json/admin/datastore/{}/pxar?{}", repo.store(), query);
|
||||||
|
|
||||||
let stream = CaTarBackupStream::open(dir_path.as_ref(), all_file_systems, verbose)?;
|
let stream = PxarBackupStream::open(dir_path.as_ref(), all_file_systems, verbose)?;
|
||||||
|
|
||||||
let body = Body::wrap_stream(stream);
|
let body = Body::wrap_stream(stream);
|
||||||
|
|
||||||
client.upload("application/x-proxmox-backup-catar", body, &path)?;
|
client.upload("application/x-proxmox-backup-pxar", body, &path)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -183,6 +183,7 @@ fn strip_chunked_file_expenstions(list: Vec<String>) -> Vec<String> {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* not used:
|
||||||
fn list_backups(
|
fn list_backups(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
@ -223,6 +224,7 @@ fn list_backups(
|
|||||||
//Ok(result)
|
//Ok(result)
|
||||||
Ok(Value::Null)
|
Ok(Value::Null)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
fn list_backup_groups(
|
fn list_backup_groups(
|
||||||
param: Value,
|
param: Value,
|
||||||
@ -474,8 +476,8 @@ fn complete_backup_source(arg: &str, param: &HashMap<String, String>) -> Vec<Str
|
|||||||
let data: Vec<&str> = arg.splitn(2, ':').collect();
|
let data: Vec<&str> = arg.splitn(2, ':').collect();
|
||||||
|
|
||||||
if data.len() != 2 {
|
if data.len() != 2 {
|
||||||
result.push(String::from("root.catar:/"));
|
result.push(String::from("root.pxar:/"));
|
||||||
result.push(String::from("etc.catar:/etc"));
|
result.push(String::from("etc.pxar:/etc"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,13 +546,13 @@ fn restore(
|
|||||||
|
|
||||||
let target = tools::required_string_param(¶m, "target")?;
|
let target = tools::required_string_param(¶m, "target")?;
|
||||||
|
|
||||||
if archive_name.ends_with(".catar") {
|
if archive_name.ends_with(".pxar") {
|
||||||
let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store(), query);
|
let path = format!("api2/json/admin/datastore/{}/pxar?{}", repo.store(), query);
|
||||||
|
|
||||||
println!("DOWNLOAD FILE {} to {}", path, target);
|
println!("DOWNLOAD FILE {} to {}", path, target);
|
||||||
|
|
||||||
let target = PathBuf::from(target);
|
let target = PathBuf::from(target);
|
||||||
let writer = CaTarBackupWriter::new(&target, true)?;
|
let writer = PxarBackupWriter::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);
|
||||||
|
@ -12,9 +12,9 @@ use serde_json::{Value};
|
|||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use proxmox_backup::catar::format_definition::*;
|
use proxmox_backup::pxar::format_definition::*;
|
||||||
use proxmox_backup::catar::encoder::*;
|
use proxmox_backup::pxar::encoder::*;
|
||||||
use proxmox_backup::catar::decoder::*;
|
use proxmox_backup::pxar::decoder::*;
|
||||||
|
|
||||||
use proxmox_backup::tools::*;
|
use proxmox_backup::tools::*;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ fn print_filenames(
|
|||||||
|
|
||||||
let mut reader = std::io::BufReader::new(file);
|
let mut reader = std::io::BufReader::new(file);
|
||||||
|
|
||||||
let mut decoder = CaTarDecoder::new(&mut reader)?;
|
let mut decoder = PxarDecoder::new(&mut reader)?;
|
||||||
|
|
||||||
let root = decoder.root();
|
let root = decoder.root();
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ fn dump_archive(
|
|||||||
let archive = tools::required_string_param(¶m, "archive")?;
|
let archive = tools::required_string_param(¶m, "archive")?;
|
||||||
let mut file = std::fs::File::open(archive)?;
|
let mut file = std::fs::File::open(archive)?;
|
||||||
|
|
||||||
println!("CATAR {}", archive);
|
println!("PXAR {}", archive);
|
||||||
|
|
||||||
let mut buffer = [0u8; 16];
|
let mut buffer = [0u8; 16];
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ fn create_archive(
|
|||||||
|
|
||||||
let mut writer = std::io::BufWriter::with_capacity(1024*1024, file);
|
let mut writer = std::io::BufWriter::with_capacity(1024*1024, file);
|
||||||
|
|
||||||
CaTarEncoder::encode(source, &mut dir, &mut writer, all_file_systems, verbose)?;
|
PxarEncoder::encode(source, &mut dir, &mut writer, all_file_systems, verbose)?;
|
||||||
|
|
||||||
writer.flush()?;
|
writer.flush()?;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ fn main() {
|
|||||||
.insert("create", CliCommand::new(
|
.insert("create", CliCommand::new(
|
||||||
ApiMethod::new(
|
ApiMethod::new(
|
||||||
create_archive,
|
create_archive,
|
||||||
ObjectSchema::new("Create new catar archive.")
|
ObjectSchema::new("Create new .pxar archive.")
|
||||||
.required("archive", StringSchema::new("Archive name"))
|
.required("archive", StringSchema::new("Archive name"))
|
||||||
.required("source", StringSchema::new("Source directory."))
|
.required("source", StringSchema::new("Source directory."))
|
||||||
.optional("verbose", BooleanSchema::new("Verbose output.").default(false))
|
.optional("verbose", BooleanSchema::new("Verbose output.").default(false))
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
mod http_client;
|
mod http_client;
|
||||||
pub use http_client::*;
|
pub use http_client::*;
|
||||||
|
|
||||||
mod catar_backup_stream;
|
mod pxar_backup_stream;
|
||||||
pub use catar_backup_stream::*;
|
pub use pxar_backup_stream::*;
|
||||||
|
|
||||||
mod catar_decode_writer;
|
mod pxar_decode_writer;
|
||||||
pub use catar_decode_writer::*;
|
pub use pxar_decode_writer::*;
|
||||||
|
|
||||||
mod backup_repo;
|
mod backup_repo;
|
||||||
pub use backup_repo::*;
|
pub use backup_repo::*;
|
||||||
|
@ -11,22 +11,22 @@ use nix::fcntl::OFlag;
|
|||||||
use nix::sys::stat::Mode;
|
use nix::sys::stat::Mode;
|
||||||
use nix::dir::Dir;
|
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
|
/// 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.
|
/// consumer.
|
||||||
///
|
///
|
||||||
/// Note: The currect implementation is not fully ansync and can block.
|
/// Note: The currect implementation is not fully ansync and can block.
|
||||||
pub struct CaTarBackupStream {
|
pub struct PxarBackupStream {
|
||||||
pipe: Option<std::fs::File>,
|
pipe: Option<std::fs::File>,
|
||||||
buffer: Vec<u8>,
|
buffer: Vec<u8>,
|
||||||
child: Option<thread::JoinHandle<()>>,
|
child: Option<thread::JoinHandle<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for CaTarBackupStream {
|
impl Drop for PxarBackupStream {
|
||||||
|
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
drop(self.pipe.take());
|
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> {
|
pub fn new(mut dir: Dir, path: PathBuf, all_file_systems: bool, verbose: bool) -> Result<Self, Error> {
|
||||||
let mut buffer = Vec::with_capacity(4096);
|
let mut buffer = Vec::with_capacity(4096);
|
||||||
@ -44,8 +44,8 @@ impl CaTarBackupStream {
|
|||||||
|
|
||||||
let child = thread::spawn(move|| {
|
let child = thread::spawn(move|| {
|
||||||
let mut writer = unsafe { std::fs::File::from_raw_fd(tx) };
|
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) {
|
if let Err(err) = PxarEncoder::encode(path, &mut dir, &mut writer, all_file_systems, verbose) {
|
||||||
eprintln!("catar encode failed - {}", err);
|
eprintln!("pxar encode failed - {}", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ impl CaTarBackupStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stream for CaTarBackupStream {
|
impl Stream for PxarBackupStream {
|
||||||
|
|
||||||
type Item = Vec<u8>;
|
type Item = Vec<u8>;
|
||||||
type Error = Error;
|
type Error = Error;
|
@ -5,16 +5,16 @@ use std::os::unix::io::FromRawFd;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::io::Write;
|
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>,
|
pipe: Option<std::fs::File>,
|
||||||
child: Option<thread::JoinHandle<()>>,
|
child: Option<thread::JoinHandle<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for CaTarBackupWriter {
|
impl Drop for PxarBackupWriter {
|
||||||
|
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
drop(self.pipe.take());
|
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 (rx, tx) = nix::unistd::pipe()?;
|
||||||
|
|
||||||
let base = PathBuf::from(base);
|
let base = PathBuf::from(base);
|
||||||
|
|
||||||
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 = CaTarDecoder::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);
|
println!("RESTORE: {:?}", path);
|
||||||
Ok(())
|
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> {
|
fn write(&mut self, buffer: &[u8]) -> Result<usize, std::io::Error> {
|
||||||
let pipe = match self.pipe {
|
let pipe = match self.pipe {
|
@ -17,7 +17,7 @@ pub mod server {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod catar;
|
pub mod pxar;
|
||||||
|
|
||||||
pub mod section_config;
|
pub mod section_config;
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
//! *catar* Implementation
|
//! *pxar* Implementation
|
||||||
//!
|
//!
|
||||||
//! This is a implementation of the *catar* format used by the
|
//! This code implements a slightly modified version of the *catar*
|
||||||
//! [casync](https://github.com/systemd/casync) toolkit. It is a file
|
//! format used in the [casync](https://github.com/systemd/casync)
|
||||||
//! archive format defined by 'Lennart Poettering', specially defined
|
//! toolkit (we are not 100% binary compatible). It is a file archive
|
||||||
//! for efficent deduplication.
|
//! format defined by 'Lennart Poettering', specially defined for
|
||||||
|
//! efficent deduplication.
|
||||||
|
|
||||||
//! Every archive contains items in the following order:
|
//! Every archive contains items in the following order:
|
||||||
//! * ENTRY -- containing general stat() data and related bits
|
//! * ENTRY -- containing general stat() data and related bits
|
@ -62,7 +62,7 @@ fn copy_binary_search_tree_inner<F: FnMut(usize, usize)>(
|
|||||||
/// info.
|
/// info.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use proxmox_backup::catar::binary_search_tree::copy_binary_search_tree;
|
/// # use proxmox_backup::pxar::binary_search_tree::copy_binary_search_tree;
|
||||||
/// copy_binary_search_tree(5, |src, dest| {
|
/// copy_binary_search_tree(5, |src, dest| {
|
||||||
/// println!("Copy {} to {}", src, dest);
|
/// println!("Copy {} to {}", src, dest);
|
||||||
/// });
|
/// });
|
@ -1,6 +1,6 @@
|
|||||||
//! *catar* format decoder.
|
//! *pxar* format decoder.
|
||||||
//!
|
//!
|
||||||
//! This module contain the code to decode *catar* archive files.
|
//! This module contain the code to decode *pxar* archive files.
|
||||||
|
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use endian_trait::Endian;
|
use endian_trait::Endian;
|
||||||
@ -22,14 +22,14 @@ use nix::errno::Errno;
|
|||||||
use nix::NixPath;
|
use nix::NixPath;
|
||||||
|
|
||||||
// This one need Read, but works without Seek
|
// This one need Read, but works without Seek
|
||||||
pub struct CaTarDecoder<'a, R: Read> {
|
pub struct PxarDecoder<'a, R: Read> {
|
||||||
reader: &'a mut R,
|
reader: &'a mut R,
|
||||||
skip_buffer: Vec<u8>,
|
skip_buffer: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const HEADER_SIZE: u64 = std::mem::size_of::<CaFormatHeader>() as u64;
|
const HEADER_SIZE: u64 = std::mem::size_of::<CaFormatHeader>() as u64;
|
||||||
|
|
||||||
impl <'a, R: Read> CaTarDecoder<'a, R> {
|
impl <'a, R: Read> PxarDecoder<'a, R> {
|
||||||
|
|
||||||
pub fn new(reader: &'a mut R) -> Self {
|
pub fn new(reader: &'a mut R) -> Self {
|
||||||
let mut skip_buffer = vec![0u8; 64*1024];
|
let mut skip_buffer = vec![0u8; 64*1024];
|
@ -1,6 +1,6 @@
|
|||||||
//! *catar* format encoder.
|
//! *pxar* format encoder.
|
||||||
//!
|
//!
|
||||||
//! This module contain the code to generate *catar* archive files.
|
//! This module contain the code to generate *pxar* archive files.
|
||||||
|
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use endian_trait::Endian;
|
use endian_trait::Endian;
|
||||||
@ -27,7 +27,7 @@ use nix::sys::stat::FileStat;
|
|||||||
/// maximum memory usage.
|
/// maximum memory usage.
|
||||||
pub const MAX_DIRECTORY_ENTRIES: usize = 256*1024;
|
pub const MAX_DIRECTORY_ENTRIES: usize = 256*1024;
|
||||||
|
|
||||||
pub struct CaTarEncoder<'a, W: Write> {
|
pub struct PxarEncoder<'a, W: Write> {
|
||||||
current_path: PathBuf, // used for error reporting
|
current_path: PathBuf, // used for error reporting
|
||||||
writer: &'a mut W,
|
writer: &'a mut W,
|
||||||
writer_pos: usize,
|
writer_pos: usize,
|
||||||
@ -38,7 +38,7 @@ pub struct CaTarEncoder<'a, W: Write> {
|
|||||||
verbose: bool,
|
verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <'a, W: Write> CaTarEncoder<'a, W> {
|
impl <'a, W: Write> PxarEncoder<'a, W> {
|
||||||
|
|
||||||
pub fn encode(
|
pub fn encode(
|
||||||
path: PathBuf,
|
path: PathBuf,
|
@ -1,4 +1,4 @@
|
|||||||
//! *catar* binary format definition
|
//! *pxar* binary format definition
|
||||||
//!
|
//!
|
||||||
//! Please note the all values are stored in little endian ordering.
|
//! Please note the all values are stored in little endian ordering.
|
||||||
//!
|
//!
|
@ -1,6 +1,6 @@
|
|||||||
//! *catar* format decoder.
|
//! *pxar* format decoder.
|
||||||
//!
|
//!
|
||||||
//! This module contain the code to decode *catar* archive files.
|
//! This module contain the code to decode *pxar* archive files.
|
||||||
|
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use endian_trait::Endian;
|
use endian_trait::Endian;
|
||||||
@ -30,7 +30,7 @@ pub struct CaDirectoryEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This one needs Read+Seek (we may want one without Seek?)
|
// This one needs Read+Seek (we may want one without Seek?)
|
||||||
pub struct CaTarDecoder<'a, R: Read + Seek> {
|
pub struct PxarDecoder<'a, R: Read + Seek> {
|
||||||
reader: &'a mut R,
|
reader: &'a mut R,
|
||||||
root_start: u64,
|
root_start: u64,
|
||||||
root_end: u64,
|
root_end: u64,
|
||||||
@ -38,7 +38,7 @@ pub struct CaTarDecoder<'a, R: Read + Seek> {
|
|||||||
|
|
||||||
const HEADER_SIZE: u64 = std::mem::size_of::<CaFormatHeader>() as u64;
|
const HEADER_SIZE: u64 = std::mem::size_of::<CaFormatHeader>() as u64;
|
||||||
|
|
||||||
impl <'a, R: Read + Seek> CaTarDecoder<'a, R> {
|
impl <'a, R: Read + Seek> PxarDecoder<'a, R> {
|
||||||
|
|
||||||
pub fn new(reader: &'a mut R) -> Result<Self, Error> {
|
pub fn new(reader: &'a mut R) -> Result<Self, Error> {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user