Skip to content

Commit

Permalink
Handle failure when clearing the db
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayprabhu authored and aditiharini committed Jan 10, 2025
1 parent 8995bff commit 6b41d7a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ async fn main() -> Result<(), Box<dyn Error>> {

if app_config.clear_db {
let db_dir = format!("{}", app_config.rocksdb_dir);
std::fs::remove_dir_all(db_dir.clone()).unwrap();
std::fs::create_dir_all(db_dir.clone()).unwrap();
warn!("Cleared db at {:?}", db_dir);
if std::path::Path::new(&db_dir).exists() {
let remove_result = std::fs::remove_dir_all(db_dir.clone());
if let Err(e) = remove_result {
error!("Failed to clear db at {:?}: {}", db_dir, e);
}
let create_result = std::fs::create_dir_all(db_dir.clone());
if let Err(e) = create_result {
error!("Failed to create db dir at {:?}: {}", db_dir, e);
}
warn!("Cleared db at {:?}", db_dir);
} else {
warn!("No db to clear at {:?}", db_dir);
}
}

if app_config.statsd.prefix == "" {
Expand Down

0 comments on commit 6b41d7a

Please sign in to comment.