From 16878dc6a29fc713f3edbe4d974fcf0017bd600d Mon Sep 17 00:00:00 2001 From: Gary Yu Date: Sat, 5 Jan 2019 13:08:49 +0800 Subject: [PATCH] fix: regression on state sync (#2289) * fix the path name of leaf snapshot * rustfmt * fix: debug format will add "" on the path name * rustfmt --- store/src/leaf_set.rs | 2 +- store/src/pmmr.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/store/src/leaf_set.rs b/store/src/leaf_set.rs index c1f718a0..f75d4e14 100644 --- a/store/src/leaf_set.rs +++ b/store/src/leaf_set.rs @@ -155,7 +155,7 @@ impl LeafSet { let mut cp_bitmap = self.bitmap.clone(); cp_bitmap.run_optimize(); - let cp_path = self.path.join(header.hash().to_string()); + let cp_path = format!("{}.{}", self.path.to_str().unwrap(), header.hash()); let mut file = BufWriter::new(File::create(cp_path)?); file.write_all(&cp_bitmap.serialize())?; file.flush()?; diff --git a/store/src/pmmr.rs b/store/src/pmmr.rs index 5f770088..bf3986a7 100644 --- a/store/src/pmmr.rs +++ b/store/src/pmmr.rs @@ -188,11 +188,12 @@ impl PMMRBackend { // If we received a rewound "snapshot" leaf_set file move it into // place so we use it. if let Some(header) = header { - let _leaf_snapshot_path = (data_dir.join(PMMR_LEAF_FILE).to_string_lossy() - + header.hash().to_string().as_ref()) - .into_owned(); - let leaf_snapshot_path = PathBuf::from(_leaf_snapshot_path); - LeafSet::copy_snapshot(&leaf_set_path, &leaf_snapshot_path)?; + let leaf_snapshot_path = format!( + "{}.{}", + data_dir.join(PMMR_LEAF_FILE).to_str().unwrap(), + header.hash() + ); + LeafSet::copy_snapshot(&leaf_set_path, &PathBuf::from(leaf_snapshot_path))?; } let leaf_set = LeafSet::open(&leaf_set_path)?;