New default paths (#11641)
This commit is contained in:
parent
4f3a128194
commit
74e9293f0f
@ -172,7 +172,9 @@ fn key_dir(location: &str, password: Option<Password>) -> Result<Box<dyn KeyDire
|
|||||||
"geth-test" => RootDiskDirectory::create(dir::geth(true))?,
|
"geth-test" => RootDiskDirectory::create(dir::geth(true))?,
|
||||||
path if path.starts_with("parity") => {
|
path if path.starts_with("parity") => {
|
||||||
let chain = path.split('-').nth(1).unwrap_or("ethereum");
|
let chain = path.split('-').nth(1).unwrap_or("ethereum");
|
||||||
let path = dir::parity(chain);
|
let mut path = dir::default_data_pathbuf();
|
||||||
|
path.push("keys");
|
||||||
|
path.push(chain);
|
||||||
RootDiskDirectory::create(path)?
|
RootDiskDirectory::create(path)?
|
||||||
},
|
},
|
||||||
path => RootDiskDirectory::create(path)?,
|
path => RootDiskDirectory::create(path)?,
|
||||||
|
@ -28,7 +28,7 @@ use std::path::{PathBuf, Path};
|
|||||||
use ethereum_types::{H64, H256};
|
use ethereum_types::{H64, H256};
|
||||||
use journaldb::Algorithm;
|
use journaldb::Algorithm;
|
||||||
use helpers::{replace_home, replace_home_and_local};
|
use helpers::{replace_home, replace_home_and_local};
|
||||||
use app_dirs::{AppInfo, get_app_root, AppDataType};
|
use app_dirs::{AppInfo, get_app_root, data_root, AppDataType};
|
||||||
// re-export platform-specific functions
|
// re-export platform-specific functions
|
||||||
use platform::*;
|
use platform::*;
|
||||||
|
|
||||||
@ -226,16 +226,38 @@ impl DatabaseDirectories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_path(t: AppDataType) -> Option<PathBuf> {
|
||||||
|
let app_info = AppInfo { name: PRODUCT, author: AUTHOR };
|
||||||
|
let old_root = get_app_root(t, &app_info).ok()?;
|
||||||
|
if old_root.exists() {
|
||||||
|
return Some(old_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut root = data_root(t).ok()?;
|
||||||
|
root.push(if LOWERCASE { "openethereum" } else { "OpenEthereum" });
|
||||||
|
Some(root)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fallback_path() -> PathBuf {
|
||||||
|
let mut p = PathBuf::new();
|
||||||
|
p.push("$HOME");
|
||||||
|
p.push(".openethereum");
|
||||||
|
p
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Default data path
|
||||||
|
pub fn default_data_pathbuf() -> PathBuf {
|
||||||
|
default_path(AppDataType::UserData).unwrap_or_else(fallback_path)
|
||||||
|
}
|
||||||
|
|
||||||
/// Default data path
|
/// Default data path
|
||||||
pub fn default_data_path() -> String {
|
pub fn default_data_path() -> String {
|
||||||
let app_info = AppInfo { name: PRODUCT, author: AUTHOR };
|
default_data_pathbuf().to_string_lossy().into_owned()
|
||||||
get_app_root(AppDataType::UserData, &app_info).map(|p| p.to_string_lossy().into_owned()).unwrap_or_else(|_| "$HOME/.parity".to_owned())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Default local path
|
/// Default local path
|
||||||
pub fn default_local_path() -> String {
|
pub fn default_local_path() -> String {
|
||||||
let app_info = AppInfo { name: PRODUCT, author: AUTHOR };
|
default_path(AppDataType::UserCache).unwrap_or_else(fallback_path).to_string_lossy().into_owned()
|
||||||
get_app_root(AppDataType::UserCache, &app_info).map(|p| p.to_string_lossy().into_owned()).unwrap_or_else(|_| "$HOME/.parity".to_owned())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Default hypervisor path
|
/// Default hypervisor path
|
||||||
@ -259,29 +281,14 @@ pub fn geth(testnet: bool) -> PathBuf {
|
|||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parity path for specific chain
|
|
||||||
pub fn parity(chain: &str) -> PathBuf {
|
|
||||||
let mut base = parity_base();
|
|
||||||
base.push(chain);
|
|
||||||
base
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
mod platform {
|
mod platform {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
pub const LOWERCASE: bool = false;
|
||||||
pub const AUTHOR: &str = "Parity";
|
pub const AUTHOR: &str = "Parity";
|
||||||
pub const PRODUCT: &str = "io.parity.ethereum";
|
pub const PRODUCT: &str = "io.parity.ethereum";
|
||||||
pub const PRODUCT_HYPERVISOR: &str = "io.parity.ethereum-updates";
|
pub const PRODUCT_HYPERVISOR: &str = "io.parity.ethereum-updates";
|
||||||
|
|
||||||
pub fn parity_base() -> PathBuf {
|
|
||||||
let mut home = super::home();
|
|
||||||
home.push("Library");
|
|
||||||
home.push("Application Support");
|
|
||||||
home.push("io.parity.ethereum");
|
|
||||||
home.push("keys");
|
|
||||||
home
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn geth_base() -> PathBuf {
|
pub fn geth_base() -> PathBuf {
|
||||||
let mut home = super::home();
|
let mut home = super::home();
|
||||||
home.push("Library");
|
home.push("Library");
|
||||||
@ -293,20 +300,11 @@ mod platform {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
mod platform {
|
mod platform {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
pub const LOWERCASE: bool = false;
|
||||||
pub const AUTHOR: &str = "Parity";
|
pub const AUTHOR: &str = "Parity";
|
||||||
pub const PRODUCT: &str = "Ethereum";
|
pub const PRODUCT: &str = "Ethereum";
|
||||||
pub const PRODUCT_HYPERVISOR: &str = "EthereumUpdates";
|
pub const PRODUCT_HYPERVISOR: &str = "EthereumUpdates";
|
||||||
|
|
||||||
pub fn parity_base() -> PathBuf {
|
|
||||||
let mut home = super::home();
|
|
||||||
home.push("AppData");
|
|
||||||
home.push("Roaming");
|
|
||||||
home.push("Parity");
|
|
||||||
home.push("Ethereum");
|
|
||||||
home.push("keys");
|
|
||||||
home
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn geth_base() -> PathBuf {
|
pub fn geth_base() -> PathBuf {
|
||||||
let mut home = super::home();
|
let mut home = super::home();
|
||||||
home.push("AppData");
|
home.push("AppData");
|
||||||
@ -319,19 +317,11 @@ mod platform {
|
|||||||
#[cfg(not(any(target_os = "macos", windows)))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
mod platform {
|
mod platform {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
pub const LOWERCASE: bool = true;
|
||||||
pub const AUTHOR: &str = "parity";
|
pub const AUTHOR: &str = "parity";
|
||||||
pub const PRODUCT: &str = "io.parity.ethereum";
|
pub const PRODUCT: &str = "io.parity.ethereum";
|
||||||
pub const PRODUCT_HYPERVISOR: &str = "io.parity.ethereum-updates";
|
pub const PRODUCT_HYPERVISOR: &str = "io.parity.ethereum-updates";
|
||||||
|
|
||||||
pub fn parity_base() -> PathBuf {
|
|
||||||
let mut home = super::home();
|
|
||||||
home.push(".local");
|
|
||||||
home.push("share");
|
|
||||||
home.push("io.parity.ethereum");
|
|
||||||
home.push("keys");
|
|
||||||
home
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn geth_base() -> PathBuf {
|
pub fn geth_base() -> PathBuf {
|
||||||
let mut home = super::home();
|
let mut home = super::home();
|
||||||
home.push(".ethereum");
|
home.push(".ethereum");
|
||||||
|
Loading…
Reference in New Issue
Block a user