diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fail.rs | 9 | ||||
-rw-r--r-- | src/file_browser.rs | 13 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/fail.rs b/src/fail.rs index 1aa1d42..80865e0 100644 --- a/src/fail.rs +++ b/src/fail.rs @@ -52,6 +52,8 @@ pub enum HError { WrongWidgetError{got: String, wanted: String}, #[fail(display = "Strip Prefix Error: {}", error)] StripPrefixError{#[cause] error: std::path::StripPrefixError}, + #[fail(display = "INofify failed: {}", error)] + INotifyError{#[cause] error: notify::Error}, } impl HError { @@ -154,3 +156,10 @@ impl From<std::path::StripPrefixError> for HError { HError::StripPrefixError{error: error} } } + +impl From<notify::Error> for HError { + fn from(error: notify::Error) -> Self { + dbg!(&error); + HError::INotifyError{error: error} + } +} diff --git a/src/file_browser.rs b/src/file_browser.rs index bb4a1a7..2c20c21 100644 --- a/src/file_browser.rs +++ b/src/file_browser.rs @@ -243,6 +243,11 @@ impl FileBrowser { let cached_files = self.get_cached_files(&dir).ok(); let main_widget = self.main_widget_mut()?; + if dir.read_dir().is_err() { + self.show_status("Can't enter! Permission denied!").log(); + return Ok(()); + } + main_widget.change_to(Box::new(move |stale, core| { let path = dir.path(); let cached_files = cached_files.clone(); @@ -383,17 +388,17 @@ impl FileBrowser { } } if !watched_dirs.contains(&cwd.path) { - self.watcher.watch(&cwd.path, RecursiveMode::NonRecursive).unwrap(); + self.watcher.watch(&cwd.path, RecursiveMode::NonRecursive)?; self.watches.push(cwd.path); } if !watched_dirs.contains(&left_dir.path) { - self.watcher.watch(&left_dir.path, RecursiveMode::NonRecursive).unwrap(); + self.watcher.watch(&left_dir.path, RecursiveMode::NonRecursive)?; self.watches.push(left_dir.path); } if let Some(preview_dir) = preview_dir { if !watched_dirs.contains(&preview_dir) && preview_dir.is_dir() { - self.watcher.watch(&preview_dir, RecursiveMode::NonRecursive).unwrap(); - self.watches.push(preview_dir); + self.watcher.watch(&preview_dir, RecursiveMode::NonRecursive)?; + self.watches.push(preview_dir); } } Ok(()) |