api: tape restore: refactor some code parts shorter
not wanting to play code golf here, but bloat in code makes it often also harder to read, so try to reduce some of that without making it to terse. No semantic change intended. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
a40ffb92ac
commit
20a04cf07c
|
@ -476,26 +476,19 @@ fn restore_full_worker(
|
||||||
}
|
}
|
||||||
|
|
||||||
let used_datastores = store_map.used_datastores();
|
let used_datastores = store_map.used_datastores();
|
||||||
task_log!(
|
let datastore_list = used_datastores
|
||||||
worker,
|
|
||||||
"Datastore(s): {}",
|
|
||||||
used_datastores
|
|
||||||
.values()
|
.values()
|
||||||
.map(|(t, _)| String::from(t.name()))
|
.map(|(t, _)| String::from(t.name()))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join(", "),
|
.join(", ");
|
||||||
);
|
task_log!(worker, "Datastore(s): {datastore_list}",);
|
||||||
|
task_log!(worker, "Drive: {drive_name}");
|
||||||
task_log!(worker, "Drive: {}", drive_name);
|
let required_media = media_id_list
|
||||||
task_log!(
|
|
||||||
worker,
|
|
||||||
"Required media list: {}",
|
|
||||||
media_id_list
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|media_id| media_id.label.label_text.as_str())
|
.map(|media_id| media_id.label.label_text.as_str())
|
||||||
.collect::<Vec<&str>>()
|
.collect::<Vec<&str>>()
|
||||||
.join(";")
|
.join(";");
|
||||||
);
|
task_log!(worker, "Required media list: {required_media}",);
|
||||||
|
|
||||||
let mut datastore_locks = Vec::new();
|
let mut datastore_locks = Vec::new();
|
||||||
for (target, _) in used_datastores.values() {
|
for (target, _) in used_datastores.values() {
|
||||||
|
@ -549,12 +542,8 @@ fn check_snapshot_restorable(
|
||||||
(datastore, namespaces)
|
(datastore, namespaces)
|
||||||
} else {
|
} else {
|
||||||
match store_map.get_targets(store, ns) {
|
match store_map.get_targets(store, ns) {
|
||||||
Some((ds, Some(ns))) => {
|
Some((_, Some(ns))) if ns.is_empty() => return Ok(false),
|
||||||
if ns.is_empty() {
|
Some((datastore, Some(ns))) => (datastore, ns),
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
(ds, ns)
|
|
||||||
}
|
|
||||||
Some((_, None)) => return Ok(false),
|
Some((_, None)) => return Ok(false),
|
||||||
None => return Ok(false),
|
None => return Ok(false),
|
||||||
}
|
}
|
||||||
|
@ -830,9 +819,7 @@ fn restore_list_worker(
|
||||||
format_err!("unexpected source datastore: {}", source_datastore)
|
format_err!("unexpected source datastore: {}", source_datastore)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let namespaces = target_ns.unwrap_or_else(|| vec![source_ns.clone()]);
|
for ns in target_ns.unwrap_or_else(|| vec![source_ns.clone()]) {
|
||||||
|
|
||||||
for ns in namespaces {
|
|
||||||
if let Err(err) = proxmox_lang::try_block!({
|
if let Err(err) = proxmox_lang::try_block!({
|
||||||
check_and_create_namespaces(
|
check_and_create_namespaces(
|
||||||
&user_info,
|
&user_info,
|
||||||
|
|
Loading…
Reference in New Issue