src/bin/proxmox-backup-client.rs: strip .didx file extensions
This commit is contained in:
parent
74cdb52107
commit
8e39232acc
@ -12,7 +12,7 @@ use std::os::unix::io::AsRawFd;
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use chrono::{Local, TimeZone};
|
use chrono::{Local, TimeZone};
|
||||||
|
|
||||||
/// Header format definition for fixed index files (`.fixd`)
|
/// Header format definition for fixed index files (`.fidx`)
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct FixedIndexHeader {
|
pub struct FixedIndexHeader {
|
||||||
/// The string `PROXMOX-FIDX`
|
/// The string `PROXMOX-FIDX`
|
||||||
|
@ -90,6 +90,23 @@ fn backup_image(datastore: &DataStore, file: &std::fs::File, size: usize, target
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
fn strip_chunked_file_expenstions(list: Vec<String>) -> Vec<String> {
|
||||||
|
|
||||||
|
let mut result = vec![];
|
||||||
|
|
||||||
|
for file in list.into_iter() {
|
||||||
|
if file.ends_with(".didx") {
|
||||||
|
result.push(file[..file.len()-5].to_owned());
|
||||||
|
} else if file.ends_with(".fidx") {
|
||||||
|
result.push(file[..file.len()-5].to_owned());
|
||||||
|
} else {
|
||||||
|
result.push(file); // should not happen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
fn list_backups(
|
fn list_backups(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
@ -117,12 +134,11 @@ fn list_backups(
|
|||||||
let backup_dir = BackupDir::new(btype, id, epoch);
|
let backup_dir = BackupDir::new(btype, id, epoch);
|
||||||
|
|
||||||
let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
|
let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
|
||||||
|
let files = strip_chunked_file_expenstions(files);
|
||||||
|
|
||||||
let info = BackupInfo { backup_dir, files };
|
for filename in files {
|
||||||
|
let path = backup_dir.relative_path().to_str().unwrap().to_owned();
|
||||||
for filename in info.files {
|
println!("{} | {}/{}", backup_dir.backup_time().format("%c"), path, filename);
|
||||||
let path = info.backup_dir.relative_path().to_str().unwrap().to_owned();
|
|
||||||
println!("{} | {}/{}", info.backup_dir.backup_time().format("%c"), path, filename);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,10 +190,8 @@ fn list_backup_groups(
|
|||||||
|
|
||||||
let path = group.group_path().to_str().unwrap().to_owned();
|
let path = group.group_path().to_str().unwrap().to_owned();
|
||||||
|
|
||||||
let files = item["files"].as_array().unwrap().iter()
|
let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
|
||||||
.map(|v| {
|
let files = strip_chunked_file_expenstions(files);
|
||||||
v.as_str().unwrap().to_owned()
|
|
||||||
}).collect();
|
|
||||||
|
|
||||||
println!("{:20} | {} | {:5} | {}", path, last_backup.format("%c"),
|
println!("{:20} | {} | {:5} | {}", path, last_backup.format("%c"),
|
||||||
backup_count, tools::join(&files, ' '));
|
backup_count, tools::join(&files, ' '));
|
||||||
@ -224,10 +238,8 @@ fn list_snapshots(
|
|||||||
|
|
||||||
let path = snapshot.relative_path().to_str().unwrap().to_owned();
|
let path = snapshot.relative_path().to_str().unwrap().to_owned();
|
||||||
|
|
||||||
let files = item["files"].as_array().unwrap().iter()
|
let files = item["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_owned()).collect();
|
||||||
.map(|v| {
|
let files = strip_chunked_file_expenstions(files);
|
||||||
v.as_str().unwrap().to_owned()
|
|
||||||
}).collect();
|
|
||||||
|
|
||||||
println!("{} | {} | {}", path, snapshot.backup_time().format("%c"), tools::join(&files, ' '));
|
println!("{} | {} | {}", path, snapshot.backup_time().format("%c"), tools::join(&files, ' '));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user