From 682a284afa3bd74a1733becd3ad7251ba103254f Mon Sep 17 00:00:00 2001 From: rabite Date: Sat, 25 Jan 2020 00:50:28 +0100 Subject: remove backtraces from HError --- src/fail.rs | 35 ++++++++++------------------------- src/fscache.rs | 16 ++++++---------- src/listview.rs | 7 ++++++- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/src/fail.rs b/src/fail.rs index 918f7df..38a66d0 100644 --- a/src/fail.rs +++ b/src/fail.rs @@ -14,22 +14,12 @@ use crate::mediaview::MediaError; pub type HResult = Result; -pub type Backtrace = Arc; -pub trait ArcBacktrace { - fn new_arced() -> Backtrace; -} - -impl ArcBacktrace for Backtrace { - fn new_arced() -> Backtrace { - Arc::new(failure::Backtrace::new()) - } -} #[derive(Fail, Debug, Clone)] pub enum HError { #[fail(display = "IO error: {} ", _0)] - IoError(String, Backtrace), + IoError(String), #[fail(display = "Mutex failed")] MutexError, #[fail(display = "Can't lock!")] @@ -47,11 +37,11 @@ pub enum HError { #[fail(display = "Accessed stale value")] StaleError, #[fail(display = "Failed: {}", _0)] - Error(String, Backtrace), + Error(String), #[fail(display = "Was None!")] - NoneError(Backtrace), + NoneError, #[fail(display = "Async Error: {}", _0)] - AError(async_value::AError, Backtrace), + AError(async_value::AError), #[fail(display = "No widget found")] NoWidgetError, #[fail(display = "Path: {:?} not in this directory: {:?}", path, dir)] @@ -75,7 +65,7 @@ pub enum HError { #[fail(display = "Strip Prefix Error: {}", error)] StripPrefixError{#[cause] error: std::path::StripPrefixError}, #[fail(display = "INofify failed: {}", _0)] - INotifyError(String, Backtrace), + INotifyError(String), #[fail(display = "Tags not loaded yet")] TagsNotLoadedYetError, #[fail(display = "Input cancelled!")] @@ -276,17 +266,14 @@ where E: Into + Clone { impl From for HError { fn from(error: std::io::Error) -> Self { - let err = HError::IoError(format!("{}", error), - Backtrace::new_arced()); + let err = HError::IoError(format!("{}", error)); err } } impl From for HError { fn from(error: failure::Error) -> Self { - let err = HError::Error(format!("{}", error), - Backtrace::new_arced() - ); + let err = HError::Error(format!("{}", error)); err } } @@ -328,7 +315,7 @@ impl From> for HError { impl From for HError { fn from(_error: std::option::NoneError) -> Self { - let err = HError::NoneError(Backtrace::new_arced()); + let err = HError::NoneError; err } } @@ -342,16 +329,14 @@ impl From for HError { impl From for HError { fn from(error: notify::Error) -> Self { - let err = HError::INotifyError(format!("{}", error), - Backtrace::new_arced()); + let err = HError::INotifyError(format!("{}", error)); err } } impl From for HError { fn from(error: async_value::AError) -> Self { - let err = HError::AError(error, - Backtrace::new_arced()); + let err = HError::AError(error); err } } diff --git a/src/fscache.rs b/src/fscache.rs index ff41b0f..bf5ab2f 100644 --- a/src/fscache.rs +++ b/src/fscache.rs @@ -10,7 +10,7 @@ use std::path::PathBuf; use crate::files::{Files, File, SortBy}; use crate::widget::Events; -use crate::fail::{HResult, HError, ErrorLog, Backtrace, ArcBacktrace}; +use crate::fail::{HResult, HError, ErrorLog}; pub type CachedFiles = (Option, Async); @@ -263,7 +263,7 @@ impl FsCache { let mut files = file_cache.read() .map_err(|e| HError::from(e))? .get(&dir) - .ok_or(HError::NoneError(Backtrace::new_arced()))? + .ok_or(HError::NoneError)? .clone(); let tab_settings = &tab_settings; @@ -406,11 +406,9 @@ impl TryFrom for FsEvent { File::new_from_path(&new_path, None)?), DebouncedEvent::Error(err, path) - => Err(HError::INotifyError(format!("{}, {:?}", err, path), - Backtrace::new_arced()))?, + => Err(HError::INotifyError(format!("{}, {:?}", err, path)))?, DebouncedEvent::Rescan - => Err(HError::INotifyError("Need to rescan".to_string(), - Backtrace::new_arced()))?, + => Err(HError::INotifyError("Need to rescan".to_string()))?, // Ignore NoticeRemove/NoticeWrite _ => None?, }; @@ -499,11 +497,9 @@ impl PathFromEvent for DebouncedEvent { DebouncedEvent::NoticeRemove(path) => Ok(path), DebouncedEvent::Rename(old_path, _) => Ok(old_path), DebouncedEvent::Error(err, path) - => Err(HError::INotifyError(format!("{}, {:?}", err, path), - Backtrace::new_arced())), + => Err(HError::INotifyError(format!("{}, {:?}", err, path))), DebouncedEvent::Rescan - => Err(HError::INotifyError("Need to rescan".to_string(), - Backtrace::new_arced())) + => Err(HError::INotifyError("Need to rescan".to_string())) } } diff --git a/src/listview.rs b/src/listview.rs index 36439b1..6a573d9 100644 --- a/src/listview.rs +++ b/src/listview.rs @@ -98,11 +98,16 @@ impl Listable for ListView { fn on_new(&mut self) -> HResult<()> { let show_hidden = self.core.config().show_hidden(); self.content.show_hidden = show_hidden; - let file = self.content + let mut file = self.content .iter_files() .nth(0) .cloned() .unwrap_or_default(); + + if !file.meta.value.is_ok() { + file.meta_sync().log(); + } + self.current_item = Some(file); Ok(()) } -- cgit v1.2.3