summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2020-01-25 00:50:28 +0100
committerrabite <rabite@posteo.de>2020-01-25 01:00:48 +0100
commit682a284afa3bd74a1733becd3ad7251ba103254f (patch)
tree1e42c91c1cf2b828f692c047e7be967136770193
parentb18e86f28e556c5834912b05c4e2e30b1d4dbd54 (diff)
remove backtraces from HError
-rw-r--r--src/fail.rs35
-rw-r--r--src/fscache.rs16
-rw-r--r--src/listview.rs7
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<T> = Result<T, HError>;
-pub type Backtrace = Arc<failure::Backtrace>;
-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<HError> + Clone {
impl From<std::io::Error> 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<failure::Error> 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<T> From<std::sync::TryLockError<T>> for HError {
impl From<std::option::NoneError> 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<std::path::StripPrefixError> for HError {
impl From<notify::Error> 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<async_value::AError> 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<File>, Async<Files>);
@@ -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<DebouncedEvent> 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<Files> {
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(())
}