Ignore dapps_policy.json (#3919)

* Ignore dapps_policy.json

* Produce warning for non-ignored files
This commit is contained in:
Tomasz Drwięga 2016-12-20 16:34:53 +01:00 committed by Arkadiy Paronyan
parent 269338d9bf
commit 9a5bb9470b
4 changed files with 14 additions and 5 deletions

1
Cargo.lock generated
View File

@ -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)",

View File

@ -5,6 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
[dependencies]
log = "0.3"
libc = "0.2.11"
rand = "0.3.14"
ethkey = { path = "../ethkey" }

View File

@ -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::<Vec<PathBuf>>();
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()
)
}
}

View File

@ -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;