crash fix

This commit is contained in:
rabite 2019-03-10 16:41:57 +01:00
parent 9fcc12f464
commit b332c4fb11
2 changed files with 18 additions and 4 deletions

View File

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

View File

@ -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(())