diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-16 16:14:17 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-16 16:14:17 -0400 |
commit | c6edd4e5d5cbcbc16063a10181aee9626822d273 (patch) | |
tree | 5524d52e5fb6f288be943c4882973dd1839a95f3 /src/commands | |
parent | 50f67156b783c3f533214ddfa8e79bd979d76278 (diff) |
better error handling for threads
- code cleanup
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/bulk_rename.rs | 6 | ||||
-rw-r--r-- | src/commands/file_ops/paste_copy.rs | 2 | ||||
-rw-r--r-- | src/commands/file_ops/paste_cut.rs | 2 | ||||
-rw-r--r-- | src/commands/set_mode.rs | 3 | ||||
-rw-r--r-- | src/commands/tab_operations.rs | 8 | ||||
-rw-r--r-- | src/commands/tab_switch.rs | 2 |
6 files changed, 11 insertions, 12 deletions
diff --git a/src/commands/bulk_rename.rs b/src/commands/bulk_rename.rs index b9f5cfc..e22be06 100644 --- a/src/commands/bulk_rename.rs +++ b/src/commands/bulk_rename.rs @@ -138,9 +138,9 @@ impl std::fmt::Display for BulkRename { impl JoshutoRunnable for BulkRename { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { backend.terminal_drop(); - Self::bulk_rename(context)?; - backend.terminal_restore(); + let res = Self::bulk_rename(context); + backend.terminal_restore()?; ReloadDirList::reload(context.curr_tab_index, context)?; - Ok(()) + res } } diff --git a/src/commands/file_ops/paste_copy.rs b/src/commands/file_ops/paste_copy.rs index 943e14f..3a430d1 100644 --- a/src/commands/file_ops/paste_copy.rs +++ b/src/commands/file_ops/paste_copy.rs @@ -55,7 +55,7 @@ pub fn paste_copy( rx_start.recv(); for path in paths { total += recursive_copy(thread_dest.as_path(), path.as_path(), &options)?; - tx.send(Event::IOWorkerProgress(total)); + tx.send(total); } Ok(total) }); diff --git a/src/commands/file_ops/paste_cut.rs b/src/commands/file_ops/paste_cut.rs index 3d1b610..fb9dc72 100644 --- a/src/commands/file_ops/paste_cut.rs +++ b/src/commands/file_ops/paste_cut.rs @@ -63,7 +63,7 @@ pub fn paste_cut( rx_start.recv(); for path in paths { total += recursive_cut(thread_dest.as_path(), path.as_path(), &options)?; - tx.send(Event::IOWorkerProgress(total)); + tx.send(total); } Ok(total) }); diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs index 7ce18a2..d23c366 100644 --- a/src/commands/set_mode.rs +++ b/src/commands/set_mode.rs @@ -1,7 +1,6 @@ use crate::commands::{CursorMoveDown, JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; -use crate::fs::JoshutoDirEntry; use crate::ui::widgets::TuiTextField; use crate::ui::TuiBackend; use crate::util::unix; @@ -77,7 +76,7 @@ impl JoshutoRunnable for SetMode { let s = &s[PREFIX.len()..]; let mode = Self::str_to_mode(s); - let mut entry = context.tabs[context.curr_tab_index] + let entry = context.tabs[context.curr_tab_index] .curr_list_mut() .and_then(|x| x.get_curr_mut()) .unwrap(); diff --git a/src/commands/tab_operations.rs b/src/commands/tab_operations.rs index 673502b..6c62d09 100644 --- a/src/commands/tab_operations.rs +++ b/src/commands/tab_operations.rs @@ -1,6 +1,6 @@ use std::path; -use crate::commands::{JoshutoCommand, JoshutoRunnable, CursorMoveStub, Quit, TabSwitch}; +use crate::commands::{CursorMoveStub, JoshutoCommand, JoshutoRunnable, Quit, TabSwitch}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::tab::JoshutoTab; @@ -60,7 +60,7 @@ impl CloseTab { "close_tab" } - pub fn close_tab(context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + pub fn close_tab(context: &mut JoshutoContext) -> JoshutoResult<()> { if context.tabs.len() <= 1 { return Quit::quit(context); } @@ -83,7 +83,7 @@ impl std::fmt::Display for CloseTab { } impl JoshutoRunnable for CloseTab { - fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { - Self::close_tab(context, backend) + fn execute(&self, context: &mut JoshutoContext, _: &mut TuiBackend) -> JoshutoResult<()> { + Self::close_tab(context) } } diff --git a/src/commands/tab_switch.rs b/src/commands/tab_switch.rs index ef911f1..cc54f57 100644 --- a/src/commands/tab_switch.rs +++ b/src/commands/tab_switch.rs @@ -36,7 +36,7 @@ impl std::fmt::Display for TabSwitch { } impl JoshutoRunnable for TabSwitch { - fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + fn execute(&self, context: &mut JoshutoContext, _: &mut TuiBackend) -> JoshutoResult<()> { let mut new_index = context.curr_tab_index as i32 + self.movement; let tab_len = context.tabs.len() as i32; while new_index < 0 { |