From 219e88a0236b20f004af6c2037a4afdb4a3c153b Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sun, 10 Apr 2016 14:20:48 +0300 Subject: [PATCH 1/2] create provided custom dir for keys if none --- util/src/keys/store.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/util/src/keys/store.rs b/util/src/keys/store.rs index 5dec27fc3..3cd85fbc2 100644 --- a/util/src/keys/store.rs +++ b/util/src/keys/store.rs @@ -184,6 +184,7 @@ impl SecretStore { /// new instance of Secret Store in specific directory pub fn new_in(path: &Path) -> Self { + ::std::fs::create_dir_all(&path).expect("Cannot access requested key directory - critical"); SecretStore { directory: KeyDirectory::new(path), unlocks: RwLock::new(HashMap::new()), From 5f7cc437dd734b284bd32feb380b5b93542fb070 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sun, 10 Apr 2016 14:38:57 +0300 Subject: [PATCH 2/2] removing lower-level defaults --- util/src/keys/store.rs | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/util/src/keys/store.rs b/util/src/keys/store.rs index 3cd85fbc2..36edb0ff1 100644 --- a/util/src/keys/store.rs +++ b/util/src/keys/store.rs @@ -121,22 +121,7 @@ impl AccountProvider for AccountService { } } -impl Default for AccountService { - fn default() -> Self { - AccountService::new() - } -} - impl AccountService { - /// New account service with the keys store in default location - pub fn new() -> Self { - let secret_store = RwLock::new(SecretStore::new()); - secret_store.write().unwrap().try_import_existing(); - AccountService { - secret_store: secret_store - } - } - /// New account service with the keys store in specific location pub fn new_in(path: &Path) -> Self { let secret_store = RwLock::new(SecretStore::new_in(path)); @@ -165,23 +150,7 @@ impl AccountService { } } - -impl Default for SecretStore { - fn default() -> Self { - SecretStore::new() - } -} - impl SecretStore { - /// new instance of Secret Store in default home directory - pub fn new() -> Self { - let mut path = ::std::env::home_dir().expect("Failed to get home dir"); - path.push(".parity"); - path.push("keys"); - ::std::fs::create_dir_all(&path).expect("Should panic since it is critical to be able to access home dir"); - Self::new_in(&path) - } - /// new instance of Secret Store in specific directory pub fn new_in(path: &Path) -> Self { ::std::fs::create_dir_all(&path).expect("Cannot access requested key directory - critical");