Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
kvdb-rocksdb: add corruption_file_name const
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva committed Jan 19, 2018
1 parent 79e1d02 commit df53656
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions util/kvdb-rocksdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn mark_corruption<T, P: AsRef<Path>>(path: P, res: result::Result<T, String>) -
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));
}
}

Expand All @@ -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> {
Database::open(&DatabaseConfig::default(), path)
Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit df53656

Please sign in to comment.