diff --git a/src/engine/sim_engine/pool.rs b/src/engine/sim_engine/pool.rs index d5e127006f..71e9dc6953 100644 --- a/src/engine/sim_engine/pool.rs +++ b/src/engine/sim_engine/pool.rs @@ -760,17 +760,20 @@ impl Pool for SimPool { } fn current_fs_metadata(&self, fs_name: Option<&str>) -> StratisResult { - self.filesystems - .iter() - .filter_map(|(name, uuid, fs)| { - if fs_name.map(|n| *n == **name).unwrap_or(true) { - Some(serde_json::to_string(&fs.record(name, *uuid)).map_err(|e| e.into())) - } else { - None - } - }) - .collect::>>() - .map(|v| v.join("\n")) + serde_json::to_string( + &self + .filesystems + .iter() + .filter_map(|(name, uuid, fs)| { + if fs_name.map(|n| *n == **name).unwrap_or(true) { + Some((uuid, fs.record(name, *uuid))) + } else { + None + } + }) + .collect::>(), + ) + .map_err(|e| e.into()) } fn last_fs_metadata(&self, fs_name: Option<&str>) -> StratisResult { diff --git a/src/engine/strat_engine/thinpool/thinpool.rs b/src/engine/strat_engine/thinpool/thinpool.rs index 4f14595ad0..97ea5d79df 100644 --- a/src/engine/strat_engine/thinpool/thinpool.rs +++ b/src/engine/strat_engine/thinpool/thinpool.rs @@ -731,33 +731,39 @@ impl ThinPool { /// Calculate filesystem metadata from current state pub fn current_fs_metadata(&self, fs_name: Option<&str>) -> StratisResult { - self.filesystems - .iter() - .filter_map(|(name, uuid, fs)| { - if fs_name.map(|n| *n == **name).unwrap_or(true) { - Some(serde_json::to_string(&fs.record(name, *uuid)).map_err(|e| e.into())) - } else { - None - } - }) - .collect::>>() - .map(|v| v.join("\n")) + serde_json::to_string( + &self + .filesystems + .iter() + .filter_map(|(name, uuid, fs)| { + if fs_name.map(|n| *n == **name).unwrap_or(true) { + Some((*uuid, fs.record(name, *uuid))) + } else { + None + } + }) + .collect::>(), + ) + .map_err(|e| e.into()) } /// Read filesystem metadata from mdv pub fn last_fs_metadata(&self, fs_name: Option<&str>) -> StratisResult { - self.mdv - .filesystems()? - .iter() - .filter_map(|fssave| { - if fs_name.map(|n| *n == fssave.name).unwrap_or(true) { - Some(serde_json::to_string(fssave).map_err(|e| e.into())) - } else { - None - } - }) - .collect::>>() - .map(|v| v.join("\n")) + serde_json::to_string( + &self + .mdv + .filesystems()? + .iter() + .filter_map(|fssave| { + if fs_name.map(|n| *n == fssave.name).unwrap_or(true) { + Some((fssave.uuid, fssave)) + } else { + None + } + }) + .collect::>(), + ) + .map_err(|e| e.into()) } }