Skip to content

Commit

Permalink
Only try to create the database if it wasn't found (#2703)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Nov 20, 2023
1 parent 1a5c35f commit a2943f5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use {
indicatif::{ProgressBar, ProgressStyle},
log::log_enabled,
redb::{
Database, MultimapTable, MultimapTableDefinition, ReadableMultimapTable, ReadableTable, Table,
TableDefinition, WriteTransaction,
Database, DatabaseError, MultimapTable, MultimapTableDefinition, ReadableMultimapTable,
ReadableTable, StorageError, Table, TableDefinition, WriteTransaction,
},
std::collections::{BTreeSet, HashMap},
std::io::{BufWriter, Read, Write},
Expand Down Expand Up @@ -261,7 +261,9 @@ impl Index {

database
}
Err(_) => {
Err(DatabaseError::Storage(StorageError::Io(error)))
if error.kind() == io::ErrorKind::NotFound =>
{
let database = Database::builder()
.set_cache_size(db_cache_size)
.create(&path)?;
Expand Down Expand Up @@ -312,6 +314,7 @@ impl Index {

database
}
Err(error) => bail!("failed to open index: {error}"),
};

let genesis_block_coinbase_transaction =
Expand Down

0 comments on commit a2943f5

Please sign in to comment.