Skip to content

Commit e220fbe

Browse files
authored
fix(l1): restore datadir path (#4050)
**Motivation** PR #4024 changed how we initialize the datadir. Instead of looking for the database in a path relative to the home directory (ie: .local/share/datadir on linux) it now looks for it on the path relative to the current directory (ie: ethrex/datadir). This caused problems when updating the ethrex commit on currently running ethrex nodes due to the DB mismatch. This PR restores the previous behaviour, and has been confirmed to work as usual on the aforementioned ethrex nodes. <!-- Why does this pull request exist? What are its goals? --> **Description** * Restore where we look for the datadir (relative to home vs current dir) <!-- A clear and concise general description of the changes this PR introduces --> <!-- Link to issues: Resolves #111, Resolves #222 --> Closes None, but is needed to continue #1676
1 parent a71da21 commit e220fbe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/ethrex/utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ pub fn default_datadir() -> String {
117117

118118
// TODO: Use PathBuf instead of strings
119119
pub fn init_datadir(data_dir: &str) -> String {
120+
let project_dir = ProjectDirs::from("", "", data_dir).expect("Couldn't find home directory");
121+
let data_dir = project_dir
122+
.data_local_dir()
123+
.to_str()
124+
.expect("invalid data directory")
125+
.to_owned();
120126
let datadir = PathBuf::from(data_dir);
121127
if datadir.exists() {
122128
if !datadir.is_dir() {

0 commit comments

Comments
 (0)