Major fixes. Make git history even messier.
This commit is contained in:
@@ -83,7 +83,7 @@ impl MapFile {
|
||||
for cluster in self.map.iter() {
|
||||
match cluster.stage {
|
||||
Stage::Untested => return Stage::Untested,
|
||||
Stage::ForIsolation(_) => {
|
||||
Stage::ForIsolation { .. } => {
|
||||
if recover_stage == Stage::Damaged || cluster.stage < recover_stage {
|
||||
// Note that recover_stage after first condition is
|
||||
// only ever Stage::ForIsolation(_), thus PartialEq,
|
||||
@@ -186,20 +186,24 @@ impl MapFile {
|
||||
});
|
||||
Some(delta)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_map_to_file(file: &mut File, map: &MapFile) -> anyhow::Result<usize> {
|
||||
let written_bytes = file.write(
|
||||
ron::ser::to_string_pretty(
|
||||
map,
|
||||
ron::ser::PrettyConfig::new()
|
||||
.new_line("\n".to_string())
|
||||
.struct_names(true),
|
||||
)?
|
||||
.as_bytes(),
|
||||
)?;
|
||||
/// Writes the map to the provided item implementing `Write` trait.
|
||||
/// Usually a file.
|
||||
pub fn write_to<W: Write>(&mut self, file: &mut W) -> anyhow::Result<usize> {
|
||||
self.defrag();
|
||||
|
||||
Ok(written_bytes)
|
||||
let written_bytes = file.write(
|
||||
ron::ser::to_string_pretty(
|
||||
self,
|
||||
ron::ser::PrettyConfig::new()
|
||||
.new_line("\n".to_string())
|
||||
.struct_names(true),
|
||||
)?
|
||||
.as_bytes(),
|
||||
)?;
|
||||
|
||||
Ok(written_bytes)
|
||||
}
|
||||
}
|
||||
|
||||
// This is split out for a shred of readability.
|
||||
@@ -730,8 +734,8 @@ mod tests {
|
||||
|
||||
let stages = vec![
|
||||
Stage::Damaged,
|
||||
Stage::ForIsolation(1),
|
||||
Stage::ForIsolation(0),
|
||||
Stage::ForIsolation { level: 1 },
|
||||
Stage::ForIsolation { level: 0 },
|
||||
Stage::Untested,
|
||||
];
|
||||
|
||||
@@ -758,19 +762,19 @@ mod tests {
|
||||
|
||||
mf.map = vec![
|
||||
*Cluster::default().set_stage(Stage::Damaged),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation(0)),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation(1)),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation { level: 0 }),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation { level: 1 }),
|
||||
Cluster::default(),
|
||||
Cluster::default(),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation(1)),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation(0)),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation { level: 1 }),
|
||||
*Cluster::default().set_stage(Stage::ForIsolation { level: 0 }),
|
||||
*Cluster::default().set_stage(Stage::Damaged),
|
||||
];
|
||||
|
||||
let stages = vec![
|
||||
Stage::Damaged,
|
||||
Stage::ForIsolation(1),
|
||||
Stage::ForIsolation(0),
|
||||
Stage::ForIsolation { level: 1 },
|
||||
Stage::ForIsolation { level: 0 },
|
||||
Stage::Untested,
|
||||
];
|
||||
|
||||
@@ -811,19 +815,19 @@ mod tests {
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 3, end: 4 },
|
||||
stage: Stage::ForIsolation(0),
|
||||
stage: Stage::ForIsolation { level: 0 },
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 4, end: 5 },
|
||||
stage: Stage::ForIsolation(0),
|
||||
stage: Stage::ForIsolation { level: 0 },
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 5, end: 6 },
|
||||
stage: Stage::ForIsolation(1),
|
||||
stage: Stage::ForIsolation { level: 1 },
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 6, end: 7 },
|
||||
stage: Stage::ForIsolation(0),
|
||||
stage: Stage::ForIsolation { level: 0 },
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 7, end: 8 },
|
||||
@@ -839,15 +843,15 @@ mod tests {
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 3, end: 5 },
|
||||
stage: Stage::ForIsolation(0),
|
||||
stage: Stage::ForIsolation { level: 0 },
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 5, end: 6 },
|
||||
stage: Stage::ForIsolation(1),
|
||||
stage: Stage::ForIsolation { level: 1 },
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 6, end: 7 },
|
||||
stage: Stage::ForIsolation(0),
|
||||
stage: Stage::ForIsolation { level: 0 },
|
||||
},
|
||||
Cluster {
|
||||
domain: Domain { start: 7, end: 8 },
|
||||
|
||||
Reference in New Issue
Block a user