src/catar/decoder.rs: implement real sequential decoder (no Seek)

I copied the old code to src/catar/inspector.rs. Will modify
that later to implement a random access decoder ...
This commit is contained in:
Dietmar Maurer
2019-03-08 16:55:54 +01:00
parent eed6db3923
commit e9c9409a99
6 changed files with 774 additions and 242 deletions

View File

@ -55,12 +55,14 @@ fn print_filenames(
_rpcenv: &mut RpcEnvironment,
) -> Result<Value, Error> {
/* FIXME
let archive = tools::required_string_param(&param, "archive")?;
let file = std::fs::File::open(archive)?;
let mut reader = std::io::BufReader::new(file);
let mut decoder = CaTarDecoder::new(&mut reader)?;
let mut decoder = CaTarDecoder::new(&mut reader)?;
let root = decoder.root();
@ -68,6 +70,9 @@ fn print_filenames(
let mut out = stdout.lock();
decoder.print_filenames(&mut out, &mut PathBuf::from("."), &root)?;
*/
panic!("not implemented");
Ok(Value::Null)
}

View File

@ -3,7 +3,8 @@ extern crate proxmox_backup;
use failure::*;
//use std::os::unix::io::AsRawFd;
use chrono::{DateTime, Local, TimeZone};
use std::path::Path;
use std::path::{Path, PathBuf};
use std::ffi::OsString;
use proxmox_backup::tools;
use proxmox_backup::cli::*;
@ -427,17 +428,15 @@ fn restore(
if file.ends_with(".catar.didx") {
let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store, query);
let mut target = std::path::PathBuf::from(target_path);
target.push(file);
target.set_extension("");
let fh = std::fs::OpenOptions::new()
.create_new(true)
.write(true)
.open(&target)?;
let mut filename = std::path::PathBuf::from(file);
filename.set_extension(""); // remove .didx
filename.set_extension(""); // remove .catar
println!("DOWNLOAD FILE {} to {:?}", path, target);
client.download(&path, Box::new(fh))?;
println!("DOWNLOAD FILE {} to {:?}", path, filename);
let writer = CaTarBackupWriter::new(
&PathBuf::from(target_path), OsString::from(filename), true)?;
client.download(&path, Box::new(writer))?;
} else {
bail!("unknown file extensions - unable to download '{}'", file);
}