From 189e0bff97ad2ceafccba77d0873b2154fd1934a Mon Sep 17 00:00:00 2001 From: John Baublitz Date: Mon, 26 Aug 2019 17:45:06 -0400 Subject: [PATCH] Implement requested changes for default_return and HashMap::collect() --- src/dbus_api/filesystem.rs | 8 +++----- src/dbus_api/pool.rs | 15 ++++++++------- src/engine/sim_engine/engine.rs | 1 - src/engine/strat_engine/backstore/metadata/bda.rs | 1 - 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/dbus_api/filesystem.rs b/src/dbus_api/filesystem.rs index 08852c52158..8a79e4f55e9 100644 --- a/src/dbus_api/filesystem.rs +++ b/src/dbus_api/filesystem.rs @@ -135,11 +135,9 @@ fn rename_filesystem(m: &MethodInfo, TData>) -> MethodResult { let (rc, rs) = (DbusErrorEnum::INTERNAL_ERROR as u16, error_message); return_message.append3(default_return, rc, rs) } - Ok(RenameAction::Identity) => return_message.append3( - (false, uuid_to_string!(FilesystemUuid::nil())), - msg_code_ok(), - msg_string_ok(), - ), + Ok(RenameAction::Identity) => { + return_message.append3(default_return, msg_code_ok(), msg_string_ok()) + } Ok(RenameAction::Renamed(uuid)) => return_message.append3( (true, uuid_to_string!(uuid)), msg_code_ok(), diff --git a/src/dbus_api/pool.rs b/src/dbus_api/pool.rs index 09d05e33b90..1f97ba25ab2 100644 --- a/src/dbus_api/pool.rs +++ b/src/dbus_api/pool.rs @@ -126,13 +126,14 @@ 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 filesystem_paths.filter_map(|path| m.tree.get(&path)) { - let uuid_option = op.get_data().as_ref().map(|d| d.uuid); - if let Some(ref uuid) = uuid_option { - filesystem_map.insert(*uuid, op.get_name().clone()); - } - } + let filesystem_map: HashMap> = filesystem_paths + .filter_map(|path| m.tree.get(&path)) + .filter_map(|op| { + op.get_data() + .as_ref() + .map(|d| (d.uuid, op.get_name().clone())) + }) + .collect(); let result = pool.destroy_filesystems( &pool_name, diff --git a/src/engine/sim_engine/engine.rs b/src/engine/sim_engine/engine.rs index 488800edd2c..a2c2fba5c40 100644 --- a/src/engine/sim_engine/engine.rs +++ b/src/engine/sim_engine/engine.rs @@ -348,5 +348,4 @@ mod tests { Ok(RenameAction::NoSource) ); } - } diff --git a/src/engine/strat_engine/backstore/metadata/bda.rs b/src/engine/strat_engine/backstore/metadata/bda.rs index 074c68b2f0a..d5b41142f07 100644 --- a/src/engine/strat_engine/backstore/metadata/bda.rs +++ b/src/engine/strat_engine/backstore/metadata/bda.rs @@ -852,5 +852,4 @@ mod tests { MetadataLocation::First, ); } - }