src/api2/admin/datastore.rs: rename get_group_list to list_groups, cleanups
This commit is contained in:
parent
184f17afad
commit
ad20d19877
@ -52,7 +52,7 @@ fn mark_selections<F: Fn(DateTime<Local>, &BackupInfo) -> String> (
|
||||
}
|
||||
}
|
||||
|
||||
fn get_group_list(
|
||||
fn list_groups(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
@ -76,10 +76,11 @@ fn get_group_list(
|
||||
let group = &info.backup_dir.group;
|
||||
|
||||
groups.push(json!({
|
||||
"backup_type": group.backup_type,
|
||||
"backup_id": group.backup_id,
|
||||
"last_backup": info.backup_dir.backup_time.timestamp(),
|
||||
"num_backups": list.len() as u64,
|
||||
"backup-type": group.backup_type,
|
||||
"backup-id": group.backup_id,
|
||||
"last-backup": info.backup_dir.backup_time.timestamp(),
|
||||
"backup-count": list.len() as u64,
|
||||
"files": info.files,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -372,7 +373,7 @@ pub fn router() -> Router {
|
||||
"groups",
|
||||
Router::new()
|
||||
.get(ApiMethod::new(
|
||||
get_group_list,
|
||||
list_groups,
|
||||
ObjectSchema::new("List backup groups.")
|
||||
.required("store", store_schema.clone()))))
|
||||
.subdir(
|
||||
|
@ -155,11 +155,11 @@ fn list_backup_groups(
|
||||
|
||||
for item in list {
|
||||
|
||||
let id = item["backup_id"].as_str().unwrap();
|
||||
let btype = item["backup_type"].as_str().unwrap();
|
||||
let epoch = item["last_backup"].as_i64().unwrap();
|
||||
let id = item["backup-id"].as_str().unwrap();
|
||||
let btype = item["backup-type"].as_str().unwrap();
|
||||
let epoch = item["last-backup"].as_i64().unwrap();
|
||||
let last_backup = Local.timestamp(epoch, 0);
|
||||
let num_backups = item["num_backups"].as_u64().unwrap();
|
||||
let backup_count = item["backup-count"].as_u64().unwrap();
|
||||
|
||||
let group = BackupGroup {
|
||||
backup_type: btype.to_string(),
|
||||
@ -167,7 +167,14 @@ fn list_backup_groups(
|
||||
};
|
||||
|
||||
let path = group.group_path().to_str().unwrap().to_owned();
|
||||
println!("{} | {} | {}", path, last_backup.format("%c"), num_backups);
|
||||
|
||||
let files = item["files"].as_array().unwrap().iter()
|
||||
.map(|v| {
|
||||
v.as_str().unwrap().to_owned()
|
||||
}).collect();
|
||||
|
||||
println!("{} | {} | {} | {}", path, last_backup.format("%c"),
|
||||
backup_count, tools::join(&files, ' '));
|
||||
}
|
||||
|
||||
//Ok(result)
|
||||
|
Loading…
Reference in New Issue
Block a user