api3/admin/datastore/catar.rs: start impl. download
This commit is contained in:
parent
50cfb695ae
commit
6a4c091616
@ -74,7 +74,7 @@ fn upload_catar(parts: Parts, req_body: Body, param: Value, _info: &ApiAsyncMeth
|
|||||||
|
|
||||||
path.push(full_archive_name);
|
path.push(full_archive_name);
|
||||||
|
|
||||||
let index = datastore.create_archive_writer(path, chunk_size).unwrap();
|
let index = datastore.create_archive_writer(path, chunk_size)?;
|
||||||
|
|
||||||
let upload = UploadCaTar { stream: req_body, index, count: 0};
|
let upload = UploadCaTar { stream: req_body, index, count: 0};
|
||||||
|
|
||||||
@ -108,6 +108,27 @@ pub fn api_method_upload_catar() -> ApiAsyncMethod {
|
|||||||
|
|
||||||
fn download_catar(parts: Parts, req_body: Body, param: Value, _info: &ApiAsyncMethod) -> Result<BoxFut, Error> {
|
fn download_catar(parts: Parts, req_body: Body, param: Value, _info: &ApiAsyncMethod) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
|
let archive_name = tools::required_string_param(¶m, "archive_name")?;
|
||||||
|
|
||||||
|
let backup_type = tools::required_string_param(¶m, "type")?;
|
||||||
|
let backup_id = tools::required_string_param(¶m, "id")?;
|
||||||
|
let backup_time = tools::required_integer_param(¶m, "time")?;
|
||||||
|
|
||||||
|
println!("Download {}.catar from {} ({}/{}/{}/{}.aidx)", archive_name, store,
|
||||||
|
backup_type, backup_id, backup_time, archive_name);
|
||||||
|
|
||||||
|
let datastore = DataStore::lookup_datastore(store)?;
|
||||||
|
|
||||||
|
let mut path = datastore.get_backup_dir(backup_type, backup_id, backup_time);
|
||||||
|
|
||||||
|
let mut full_archive_name = PathBuf::from(archive_name);
|
||||||
|
full_archive_name.set_extension("aidx");
|
||||||
|
|
||||||
|
path.push(full_archive_name);
|
||||||
|
|
||||||
|
let index = datastore.open_archive_reader(path)?;
|
||||||
|
|
||||||
bail!("not implemeneted");
|
bail!("not implemeneted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,27 @@ impl DataStore {
|
|||||||
self.chunk_store.base_path()
|
self.chunk_store.base_path()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_backup_dir(
|
||||||
|
&self,
|
||||||
|
backup_type: &str,
|
||||||
|
backup_id: &str,
|
||||||
|
backup_time: i64,
|
||||||
|
) -> PathBuf {
|
||||||
|
|
||||||
|
let mut relative_path = PathBuf::new();
|
||||||
|
|
||||||
|
relative_path.push(backup_type);
|
||||||
|
|
||||||
|
relative_path.push(backup_id);
|
||||||
|
|
||||||
|
let dt = Utc.timestamp(backup_time, 0);
|
||||||
|
let date_str = dt.format("%Y-%m-%dT%H:%M:%S").to_string();
|
||||||
|
|
||||||
|
relative_path.push(&date_str);
|
||||||
|
|
||||||
|
relative_path
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_backup_dir(
|
pub fn create_backup_dir(
|
||||||
&self,
|
&self,
|
||||||
backup_type: &str,
|
backup_type: &str,
|
||||||
|
Loading…
Reference in New Issue
Block a user