Skip to content

Commit

Permalink
Add migration code for restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanjay176 committed Aug 17, 2020
1 parent a4c33cd commit 8a7c130
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lighthouse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ account_manager = { "path" = "../account_manager" }
clap_utils = { path = "../common/clap_utils" }
eth2_testnet_config = { path = "../common/eth2_testnet_config" }
lighthouse_version = { path = "../common/lighthouse_version" }
dirs = "2.0.2"

[dev-dependencies]
tempfile = "3.1.0"
Expand Down
19 changes: 19 additions & 0 deletions lighthouse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,25 @@ fn run<E: EthSpec>(
optional_testnet_config = clap_utils::parse_testnet_dir(matches, "testnet-dir")?;
};

// WARNING: Temporary migration code for directory restructure
// Remove after reasonably sure most users have migrated.
let default_dir = dirs::home_dir()
.map(|home| home.join(DEFAULT_DATA_DIR))
.unwrap_or_else(|| PathBuf::from("."));
let testnet_dir = default_dir.join(clap_utils::get_testnet_dir(matches));

if !matches.is_present("datadir") && !testnet_dir.exists() {
std::fs::create_dir_all(&testnet_dir)
.map_err(|e| format!("Failed to create testnet directory: {}", e))?;
for dir in ["validators", "wallets", "secrets", "beacon"].iter() {
let old_path = default_dir.join(dir);
if old_path.exists() {
std::fs::rename(old_path, testnet_dir.join(dir))
.map_err(|e| format!("Failed to move directory: {}", e))?;
}
}
}

let builder = if let Some(log_path) = matches.value_of("logfile") {
let path = log_path
.parse::<PathBuf>()
Expand Down

0 comments on commit 8a7c130

Please sign in to comment.