diff --git a/Cargo.lock b/Cargo.lock index 70dd070f4..46c6aaa3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -665,6 +665,7 @@ dependencies = [ "itertools 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ethstore/Cargo.toml b/ethstore/Cargo.toml index f47d9171f..cbb3741e9 100644 --- a/ethstore/Cargo.toml +++ b/ethstore/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Parity Technologies "] build = "build.rs" [dependencies] +log = "0.3" libc = "0.2.11" rand = "0.3.14" ethkey = { path = "../ethkey" } diff --git a/ethstore/src/dir/disk.rs b/ethstore/src/dir/disk.rs index d049def48..f0674d835 100644 --- a/ethstore/src/dir/disk.rs +++ b/ethstore/src/dir/disk.rs @@ -22,7 +22,7 @@ use {json, SafeAccount, Error}; use json::Uuid; use super::KeyDirectory; -const IGNORED_FILES: &'static [&'static str] = &["thumbs.db", "address_book.json"]; +const IGNORED_FILES: &'static [&'static str] = &["thumbs.db", "address_book.json", "dapps_policy.json"]; #[cfg(not(windows))] fn restrict_permissions_to_owner(file_path: &Path) -> Result<(), i32> { @@ -78,7 +78,7 @@ impl DiskDirectory { .map(|entry| entry.path()) .collect::>(); - paths + Ok(paths .iter() .map(|p| ( fs::File::open(p) @@ -86,13 +86,17 @@ impl DiskDirectory { .and_then(|r| json::KeyFile::load(r).map_err(|e| Error::Custom(format!("{:?}", e)))), p )) - .map(|(file, path)| match file { - Ok(file) => Ok((path.clone(), SafeAccount::from_file( + .filter_map(|(file, path)| match file { + Ok(file) => Some((path.clone(), SafeAccount::from_file( file, Some(path.file_name().and_then(|n| n.to_str()).expect("Keys have valid UTF8 names only.").to_owned()) ))), - Err(err) => Err(Error::InvalidKeyFile(format!("{:?}: {}", path, err))), + Err(err) => { + warn!("Invalid key file: {:?} ({})", path, err); + None + }, }) .collect() + ) } } diff --git a/ethstore/src/lib.rs b/ethstore/src/lib.rs index e38b04ee4..b960bfd9a 100644 --- a/ethstore/src/lib.rs +++ b/ethstore/src/lib.rs @@ -32,6 +32,9 @@ extern crate parking_lot; extern crate ethkey as _ethkey; extern crate ethcrypto as crypto; +#[macro_use] +extern crate log; + #[macro_use] extern crate lazy_static;