Merge pull request #1461 from ethcore/db-repair

Attempt DB repair if corrupted
This commit is contained in:
Arkadiy Paronyan
2016-06-28 07:37:49 +02:00
committed by GitHub
2 changed files with 12 additions and 3 deletions

View File

@@ -199,7 +199,16 @@ impl Database {
opts.set_block_based_table_factory(&block_opts);
opts.set_prefix_extractor_fixed_size(size);
}
let db = try!(DB::open(&opts, path));
let db = match DB::open(&opts, path) {
Ok(db) => db,
Err(ref s) if s.starts_with("Corruption:") => {
info!("{}", s);
info!("Attempting DB repair for {}", path);
try!(DB::repair(&opts, path));
try!(DB::open(&opts, path))
},
Err(s) => { return Err(s); }
};
Ok(Database { db: db })
}