From 41d2b94e459c355b2699aa2dbd8b88c769d2467f Mon Sep 17 00:00:00 2001 From: John Baublitz Date: Wed, 25 Sep 2019 12:35:26 -0400 Subject: [PATCH] Reinstate change for filtering out invalid object paths instead of failing per discussion in #1634 --- src/dbus_api/pool.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dbus_api/pool.rs b/src/dbus_api/pool.rs index 77082f72029..7a4a7ae8fa3 100644 --- a/src/dbus_api/pool.rs +++ b/src/dbus_api/pool.rs @@ -127,13 +127,15 @@ fn destroy_filesystems(m: &MethodInfo, TData>) -> MethodResult { let mut engine = dbus_context.engine.borrow_mut(); let (pool_name, pool) = get_mut_pool!(engine; pool_uuid; default_return; return_message); - let mut filesystem_map: HashMap> = HashMap::new(); - for op in filesystems { - if let Some(filesystem_path) = m.tree.get(&op) { - let filesystem_uuid = get_data!(filesystem_path; default_return; return_message).uuid; - filesystem_map.insert(filesystem_uuid, op); - } - } + let filesystem_map: HashMap> = filesystems + .filter_map(|path| { + m.tree.get(&path).and_then(|op| { + op.get_data() + .as_ref() + .map(|d| (d.uuid, op.get_name().clone())) + }) + }) + .collect(); let result = pool.destroy_filesystems( &pool_name,