From 464516d01dd02b43d434155dd8f6a1a3e730bfc7 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 10 Aug 2016 16:42:15 +0200 Subject: [PATCH] fixed #1889, .DS_Store is no longer treated as key file (#1892) * fixed #1889, .DS_Store is no longer treated as key file * ethstore filters directories, hidden files and common system files * fixed compiling --- ethstore/src/dir/disk.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ethstore/src/dir/disk.rs b/ethstore/src/dir/disk.rs index d48fa1b58..f06870b76 100644 --- a/ethstore/src/dir/disk.rs +++ b/ethstore/src/dir/disk.rs @@ -22,6 +22,8 @@ use ethkey::Address; use {json, SafeAccount, Error}; use super::KeyDirectory; +const IGNORED_FILES: &'static [&'static str] = &["thumbs.db"]; + #[cfg(not(windows))] fn restrict_permissions_to_owner(file_path: &Path) -> Result<(), i32> { use std::ffi; @@ -62,7 +64,14 @@ impl DiskDirectory { .flat_map(Result::ok) .filter(|entry| { let metadata = entry.metadata(); - metadata.is_ok() && !metadata.unwrap().is_dir() + let file_name = entry.file_name(); + let name = file_name.to_str().unwrap(); + // filter directories + metadata.is_ok() && !metadata.unwrap().is_dir() && + // hidden files + !name.starts_with(".") && + // other ignored files + !IGNORED_FILES.contains(&name) }) .map(|entry| entry.path()) .collect::>();