From df5365610948c1807fb4f8269801791b2f94ad1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Fri, 19 Jan 2018 02:15:17 +0000 Subject: [PATCH] kvdb-rocksdb: add corruption_file_name const --- util/kvdb-rocksdb/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/kvdb-rocksdb/src/lib.rs b/util/kvdb-rocksdb/src/lib.rs index e8fab5d1f0e..0ca6bcba1bd 100644 --- a/util/kvdb-rocksdb/src/lib.rs +++ b/util/kvdb-rocksdb/src/lib.rs @@ -262,7 +262,7 @@ fn mark_corruption>(path: P, res: result::Result) - if let Err(ref s) = res { if s.starts_with("Corruption:") { warn!("DB corrupted: {}. Repair will be triggered on next restart", s); - let _ = fs::File::create(path.as_ref().join("CORRUPTED")); + let _ = fs::File::create(path.as_ref().join(Database::CORRUPTION_FILE_NAME)); } } @@ -274,6 +274,8 @@ fn is_corrupted(s: &str) -> bool { } impl Database { + pub const CORRUPTION_FILE_NAME: &'static str = "CORRUPTED"; + /// Open database with default settings. pub fn open_default(path: &str) -> Result { Database::open(&DatabaseConfig::default(), path) @@ -304,7 +306,7 @@ impl Database { } // attempt database repair if it has been previously marked as corrupted - let db_corrupted = Path::new(path).join("CORRUPTED"); + let db_corrupted = Path::new(path).join(Database::CORRUPTION_FILE_NAME); if db_corrupted.exists() { warn!("DB has been previously marked as corrupted, attempting repair"); DB::repair(&opts, path)?;