Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): don't init datadir if it doesn't exist in db command #9264

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/cli/commands/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ impl EnvironmentArgs {
let db_path = data_dir.db();
let sf_path = data_dir.static_files();

if access.is_read_write() {
reth_fs_util::create_dir_all(&db_path)?;
reth_fs_util::create_dir_all(&sf_path)?;
// ensure the provided datadir exist
if !db_path.is_dir() {
return Err(eyre::eyre!("Database path does not exist: {:?}", db_path));
}
if !sf_path.is_dir() {
return Err(eyre::eyre!("Static files path does not exist: {:?}", sf_path));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't the right location to apply this check, because this is also used by other commands.

we should apply this here:

let data_dir = self.env.datadir.clone().resolve_datadir(self.env.chain.chain);
let db_path = data_dir.db();
let static_files_path = data_dir.static_files();

because all commands here are useless if the datadir does not exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, updated the code


let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
Expand Down