Skip to content

Commit

Permalink
Don't create default data directory if --index overrides it (ordinals…
Browse files Browse the repository at this point in the history
  • Loading branch information
gmart7t2 authored and Raylin51 committed Aug 11, 2023
1 parent 5a0acf2 commit 9fdd5e5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,19 @@ impl Index {
pub(crate) fn open(options: &Options) -> Result<Self> {
let client = options.bitcoin_rpc_client()?;

let data_dir = options.data_dir()?;

if let Err(err) = fs::create_dir_all(&data_dir) {
bail!("failed to create data dir `{}`: {err}", data_dir.display());
}

let path = if let Some(path) = &options.index {
path.clone()
} else {
data_dir.join("index.redb")
options.data_dir()?.join("index.redb")
};

if let Err(err) = fs::create_dir_all(path.parent().unwrap()) {
bail!(
"failed to create data dir `{}`: {err}",
path.parent().unwrap().display()
);
}

let db_cache_size = match options.db_cache_size {
Some(db_cache_size) => db_cache_size,
None => {
Expand Down

0 comments on commit 9fdd5e5

Please sign in to comment.