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::*;
|
||||
|
||||
mod catar;
|
||||
mod pxar;
|
||||
mod upload;
|
||||
|
||||
fn group_backups(backup_list: Vec<BackupInfo>) -> HashMap<String, Vec<BackupInfo>> {
|
||||
@ -380,7 +380,7 @@ pub fn router() -> Router {
|
||||
.get(ApiMethod::new(
|
||||
|_,_,_| Ok(json!([
|
||||
{"subdir": "backups" },
|
||||
{"subdir": "catar" },
|
||||
{"subdir": "pxar" },
|
||||
{"subdir": "gc" },
|
||||
{"subdir": "groups" },
|
||||
{"subdir": "snapshots" },
|
||||
@ -398,10 +398,10 @@ pub fn router() -> Router {
|
||||
ObjectSchema::new("List backups.")
|
||||
.required("store", store_schema.clone()))))
|
||||
.subdir(
|
||||
"catar",
|
||||
"pxar",
|
||||
Router::new()
|
||||
.download(catar::api_method_download_catar())
|
||||
.upload(catar::api_method_upload_catar()))
|
||||
.download(pxar::api_method_download_pxar())
|
||||
.upload(pxar::api_method_upload_pxar()))
|
||||
.subdir(
|
||||
"test-upload",
|
||||
Router::new()
|
||||
|
@ -18,13 +18,13 @@ use std::sync::Arc;
|
||||
use hyper::Body;
|
||||
use hyper::http::request::Parts;
|
||||
|
||||
pub struct UploadCaTar {
|
||||
pub struct UploadPxar {
|
||||
stream: Body,
|
||||
index: DynamicIndexWriter,
|
||||
count: usize,
|
||||
}
|
||||
|
||||
impl Future for UploadCaTar {
|
||||
impl Future for UploadPxar {
|
||||
type Item = ();
|
||||
type Error = failure::Error;
|
||||
|
||||
@ -46,7 +46,7 @@ impl Future for UploadCaTar {
|
||||
}
|
||||
}
|
||||
|
||||
fn upload_catar(
|
||||
fn upload_pxar(
|
||||
parts: Parts,
|
||||
req_body: Body,
|
||||
param: Value,
|
||||
@ -57,8 +57,8 @@ fn upload_catar(
|
||||
let store = tools::required_string_param(¶m, "store")?;
|
||||
let mut archive_name = String::from(tools::required_string_param(¶m, "archive-name")?);
|
||||
|
||||
if !archive_name.ends_with(".catar") {
|
||||
bail!("got wront file extension (expected '.catar')");
|
||||
if !archive_name.ends_with(".pxar") {
|
||||
bail!("got wront file extension (expected '.pxar')");
|
||||
}
|
||||
|
||||
archive_name.push_str(".didx");
|
||||
@ -72,8 +72,8 @@ fn upload_catar(
|
||||
let content_type = parts.headers.get(http::header::CONTENT_TYPE)
|
||||
.ok_or(format_err!("missing content-type header"))?;
|
||||
|
||||
if content_type != "application/x-proxmox-backup-catar" {
|
||||
bail!("got wrong content-type for catar archive upload");
|
||||
if content_type != "application/x-proxmox-backup-pxar" {
|
||||
bail!("got wrong content-type for pxar archive upload");
|
||||
}
|
||||
|
||||
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 upload = UploadCaTar { stream: req_body, index, count: 0};
|
||||
let upload = UploadPxar { stream: req_body, index, count: 0};
|
||||
|
||||
let resp = upload.and_then(|_| {
|
||||
|
||||
@ -103,10 +103,10 @@ fn upload_catar(
|
||||
Ok(Box::new(resp))
|
||||
}
|
||||
|
||||
pub fn api_method_upload_catar() -> ApiAsyncMethod {
|
||||
pub fn api_method_upload_pxar() -> ApiAsyncMethod {
|
||||
ApiAsyncMethod::new(
|
||||
upload_catar,
|
||||
ObjectSchema::new("Upload .catar backup file.")
|
||||
upload_pxar,
|
||||
ObjectSchema::new("Upload .pxar backup file.")
|
||||
.required("store", StringSchema::new("Datastore name."))
|
||||
.required("archive-name", StringSchema::new("Backup archive name."))
|
||||
.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,
|
||||
_req_body: Body,
|
||||
param: Value,
|
||||
@ -135,7 +135,7 @@ fn download_catar(
|
||||
let store = tools::required_string_param(¶m, "store")?;
|
||||
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");
|
||||
} else {
|
||||
archive_name.push_str(".didx");
|
||||
@ -167,10 +167,10 @@ fn download_catar(
|
||||
Ok(Box::new(future::ok(response)))
|
||||
}
|
||||
|
||||
pub fn api_method_download_catar() -> ApiAsyncMethod {
|
||||
pub fn api_method_download_pxar() -> ApiAsyncMethod {
|
||||
ApiAsyncMethod::new(
|
||||
download_catar,
|
||||
ObjectSchema::new("Download .catar backup file.")
|
||||
download_pxar,
|
||||
ObjectSchema::new("Download .pxar backup file.")
|
||||
.required("store", StringSchema::new("Datastore name."))
|
||||
.required("archive-name", StringSchema::new("Backup archive name."))
|
||||
.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 {
|
||||
ApiAsyncMethod::new(
|
||||
upgrade_upload,
|
||||
ObjectSchema::new("Download .catar backup file.")
|
||||
ObjectSchema::new("Download .pxar backup file.")
|
||||
.required("store", StringSchema::new("Datastore name.")),
|
||||
)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ impl DynamicIndexReader {
|
||||
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);
|
||||
|
||||
|
@ -14,7 +14,7 @@ use proxmox_backup::client::*;
|
||||
use proxmox_backup::backup::*;
|
||||
//use proxmox_backup::backup::image_index::*;
|
||||
//use proxmox_backup::config::datastore;
|
||||
//use proxmox_backup::catar::encoder::*;
|
||||
//use proxmox_backup::pxar::encoder::*;
|
||||
//use proxmox_backup::backup::datastore::*;
|
||||
|
||||
use serde_json::{json, Value};
|
||||
@ -26,7 +26,7 @@ use xdg::BaseDirectories;
|
||||
use 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 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);
|
||||
|
||||
client.upload("application/x-proxmox-backup-catar", body, &path)?;
|
||||
client.upload("application/x-proxmox-backup-pxar", body, &path)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -183,6 +183,7 @@ fn strip_chunked_file_expenstions(list: Vec<String>) -> Vec<String> {
|
||||
result
|
||||
}
|
||||
|
||||
/* not used:
|
||||
fn list_backups(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
@ -223,6 +224,7 @@ fn list_backups(
|
||||
//Ok(result)
|
||||
Ok(Value::Null)
|
||||
}
|
||||
*/
|
||||
|
||||
fn list_backup_groups(
|
||||
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();
|
||||
|
||||
if data.len() != 2 {
|
||||
result.push(String::from("root.catar:/"));
|
||||
result.push(String::from("etc.catar:/etc"));
|
||||
result.push(String::from("root.pxar:/"));
|
||||
result.push(String::from("etc.pxar:/etc"));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -544,13 +546,13 @@ fn restore(
|
||||
|
||||
let target = tools::required_string_param(¶m, "target")?;
|
||||
|
||||
if archive_name.ends_with(".catar") {
|
||||
let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store(), query);
|
||||
if archive_name.ends_with(".pxar") {
|
||||
let path = format!("api2/json/admin/datastore/{}/pxar?{}", repo.store(), query);
|
||||
|
||||
println!("DOWNLOAD FILE {} to {}", path, target);
|
||||
|
||||
let target = PathBuf::from(target);
|
||||
let writer = CaTarBackupWriter::new(&target, true)?;
|
||||
let writer = PxarBackupWriter::new(&target, true)?;
|
||||
client.download(&path, Box::new(writer))?;
|
||||
} else {
|
||||
bail!("unknown file extensions - unable to download '{}'", archive_name);
|
||||
|
@ -12,9 +12,9 @@ use serde_json::{Value};
|
||||
use std::io::{Read, Write};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use proxmox_backup::catar::format_definition::*;
|
||||
use proxmox_backup::catar::encoder::*;
|
||||
use proxmox_backup::catar::decoder::*;
|
||||
use proxmox_backup::pxar::format_definition::*;
|
||||
use proxmox_backup::pxar::encoder::*;
|
||||
use proxmox_backup::pxar::decoder::*;
|
||||
|
||||
use proxmox_backup::tools::*;
|
||||
|
||||
@ -62,7 +62,7 @@ fn print_filenames(
|
||||
|
||||
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();
|
||||
|
||||
@ -86,7 +86,7 @@ fn dump_archive(
|
||||
let archive = tools::required_string_param(¶m, "archive")?;
|
||||
let mut file = std::fs::File::open(archive)?;
|
||||
|
||||
println!("CATAR {}", archive);
|
||||
println!("PXAR {}", archive);
|
||||
|
||||
let mut buffer = [0u8; 16];
|
||||
|
||||
@ -149,7 +149,7 @@ fn create_archive(
|
||||
|
||||
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()?;
|
||||
|
||||
@ -162,7 +162,7 @@ fn main() {
|
||||
.insert("create", CliCommand::new(
|
||||
ApiMethod::new(
|
||||
create_archive,
|
||||
ObjectSchema::new("Create new catar archive.")
|
||||
ObjectSchema::new("Create new .pxar archive.")
|
||||
.required("archive", StringSchema::new("Archive name"))
|
||||
.required("source", StringSchema::new("Source directory."))
|
||||
.optional("verbose", BooleanSchema::new("Verbose output.").default(false))
|
||||
|
@ -6,11 +6,11 @@
|
||||
mod http_client;
|
||||
pub use http_client::*;
|
||||
|
||||
mod catar_backup_stream;
|
||||
pub use catar_backup_stream::*;
|
||||
mod pxar_backup_stream;
|
||||
pub use pxar_backup_stream::*;
|
||||
|
||||
mod catar_decode_writer;
|
||||
pub use catar_decode_writer::*;
|
||||
mod pxar_decode_writer;
|
||||
pub use pxar_decode_writer::*;
|
||||
|
||||
mod backup_repo;
|
||||
pub use backup_repo::*;
|
||||
|
@ -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;
|
@ -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 {
|
@ -17,7 +17,7 @@ pub mod server {
|
||||
|
||||
}
|
||||
|
||||
pub mod catar;
|
||||
pub mod pxar;
|
||||
|
||||
pub mod section_config;
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
//! *catar* Implementation
|
||||
//! *pxar* Implementation
|
||||
//!
|
||||
//! This is a implementation of the *catar* format used by the
|
||||
//! [casync](https://github.com/systemd/casync) toolkit. It is a file
|
||||
//! archive format defined by 'Lennart Poettering', specially defined
|
||||
//! for efficent deduplication.
|
||||
//! This code implements a slightly modified version of the *catar*
|
||||
//! format used in the [casync](https://github.com/systemd/casync)
|
||||
//! toolkit (we are not 100% binary compatible). It is a file archive
|
||||
//! format defined by 'Lennart Poettering', specially defined for
|
||||
//! efficent deduplication.
|
||||
|
||||
//! Every archive contains items in the following order:
|
||||
//! * ENTRY -- containing general stat() data and related bits
|
@ -62,7 +62,7 @@ fn copy_binary_search_tree_inner<F: FnMut(usize, usize)>(
|
||||
/// 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| {
|
||||
/// 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 endian_trait::Endian;
|
||||
@ -22,14 +22,14 @@ use nix::errno::Errno;
|
||||
use nix::NixPath;
|
||||
|
||||
// This one need Read, but works without Seek
|
||||
pub struct CaTarDecoder<'a, R: Read> {
|
||||
pub struct PxarDecoder<'a, R: Read> {
|
||||
reader: &'a mut R,
|
||||
skip_buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
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 {
|
||||
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 endian_trait::Endian;
|
||||
@ -27,7 +27,7 @@ use nix::sys::stat::FileStat;
|
||||
/// maximum memory usage.
|
||||
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
|
||||
writer: &'a mut W,
|
||||
writer_pos: usize,
|
||||
@ -38,7 +38,7 @@ pub struct CaTarEncoder<'a, W: Write> {
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
impl <'a, W: Write> CaTarEncoder<'a, W> {
|
||||
impl <'a, W: Write> PxarEncoder<'a, W> {
|
||||
|
||||
pub fn encode(
|
||||
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.
|
||||
//!
|
@ -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 endian_trait::Endian;
|
||||
@ -30,7 +30,7 @@ pub struct CaDirectoryEntry {
|
||||
}
|
||||
|
||||
// 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,
|
||||
root_start: 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;
|
||||
|
||||
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> {
|
||||
|
Loading…
Reference in New Issue
Block a user