diff --git a/src/ui/activities/filetransfer_activity/actions.rs b/src/ui/activities/filetransfer_activity/actions.rs index 8dcf9db..e1bdd4a 100644 --- a/src/ui/activities/filetransfer_activity/actions.rs +++ b/src/ui/activities/filetransfer_activity/actions.rs @@ -36,12 +36,12 @@ impl FileTransferActivity { /// /// Enter a directory on local host from entry /// Return true whether the directory changed - pub(super) fn action_enter_local_dir(&mut self, entry: FsEntry) -> bool { + pub(super) fn action_enter_local_dir(&mut self, entry: FsEntry, block_sync: bool) -> bool { match entry { FsEntry::Directory(dir) => { - self.remote_changedir(dir.abs_path.as_path(), true); - if self.browser.sync_browsing { - self.action_change_remote_dir(dir.name.clone()); + self.local_changedir(dir.abs_path.as_path(), true); + if self.browser.sync_browsing && !block_sync { + self.action_change_remote_dir(dir.name, true); } true } @@ -51,10 +51,10 @@ impl FileTransferActivity { // If symlink and is directory, point to symlink match &**symlink_entry { FsEntry::Directory(dir) => { - self.remote_changedir(dir.abs_path.as_path(), true); + self.local_changedir(dir.abs_path.as_path(), true); // Check whether to sync - if self.browser.sync_browsing { - self.action_change_remote_dir(dir.name.clone()); + if self.browser.sync_browsing && !block_sync { + self.action_change_remote_dir(dir.name.clone(), true); } true } @@ -71,12 +71,12 @@ impl FileTransferActivity { /// /// Enter a directory on local host from entry /// Return true whether the directory changed - pub(super) fn action_enter_remote_dir(&mut self, entry: FsEntry) -> bool { + pub(super) fn action_enter_remote_dir(&mut self, entry: FsEntry, block_sync: bool) -> bool { match entry { FsEntry::Directory(dir) => { - self.local_changedir(dir.abs_path.as_path(), true); - if self.browser.sync_browsing { - self.action_change_local_dir(dir.name.clone()); + self.remote_changedir(dir.abs_path.as_path(), true); + if self.browser.sync_browsing && !block_sync { + self.action_change_local_dir(dir.name, true); } true } @@ -86,10 +86,10 @@ impl FileTransferActivity { // If symlink and is directory, point to symlink match &**symlink_entry { FsEntry::Directory(dir) => { - self.local_changedir(dir.abs_path.as_path(), true); + self.remote_changedir(dir.abs_path.as_path(), true); // Check whether to sync - if self.browser.sync_browsing { - self.action_change_local_dir(dir.name.clone()); + if self.browser.sync_browsing && !block_sync { + self.action_change_local_dir(dir.name.clone(), true); } true } @@ -105,36 +105,36 @@ impl FileTransferActivity { /// ### action_change_local_dir /// /// Change local directory reading value from input - pub(super) fn action_change_local_dir(&mut self, input: String) { + pub(super) fn action_change_local_dir(&mut self, input: String, block_sync: bool) { let dir_path: PathBuf = self.local_to_abs_path(PathBuf::from(input.as_str()).as_path()); self.local_changedir(dir_path.as_path(), true); // Check whether to sync - if self.browser.sync_browsing { - self.action_change_remote_dir(input); + if self.browser.sync_browsing && !block_sync { + self.action_change_remote_dir(input, true); } } /// ### action_change_remote_dir /// /// Change remote directory reading value from input - pub(super) fn action_change_remote_dir(&mut self, input: String) { + pub(super) fn action_change_remote_dir(&mut self, input: String, block_sync: bool) { let dir_path: PathBuf = self.remote_to_abs_path(PathBuf::from(input.as_str()).as_path()); self.remote_changedir(dir_path.as_path(), true); // Check whether to sync - if self.browser.sync_browsing { - self.action_change_local_dir(input); + if self.browser.sync_browsing && !block_sync { + self.action_change_local_dir(input, true); } } /// ### action_go_to_previous_local_dir /// /// Go to previous directory from localhost - pub(super) fn action_go_to_previous_local_dir(&mut self) { + pub(super) fn action_go_to_previous_local_dir(&mut self, block_sync: bool) { if let Some(d) = self.local.popd() { self.local_changedir(d.as_path(), false); // Check whether to sync - if self.browser.sync_browsing { - self.action_go_to_previous_remote_dir(); + if self.browser.sync_browsing && !block_sync { + self.action_go_to_previous_remote_dir(true); } } } @@ -142,12 +142,12 @@ impl FileTransferActivity { /// ### action_go_to_previous_remote_dir /// /// Go to previous directory from remote host - pub(super) fn action_go_to_previous_remote_dir(&mut self) { - if let Some(d) = self.local.popd() { + pub(super) fn action_go_to_previous_remote_dir(&mut self, block_sync: bool) { + if let Some(d) = self.remote.popd() { self.remote_changedir(d.as_path(), false); // Check whether to sync - if self.browser.sync_browsing { - self.action_go_to_previous_local_dir(); + if self.browser.sync_browsing && !block_sync { + self.action_go_to_previous_local_dir(true); } } } @@ -155,15 +155,15 @@ impl FileTransferActivity { /// ### action_go_to_local_upper_dir /// /// Go to upper directory on local host - pub(super) fn action_go_to_local_upper_dir(&mut self) { + pub(super) fn action_go_to_local_upper_dir(&mut self, block_sync: bool) { // Get pwd let path: PathBuf = self.local.wrkdir.clone(); // Go to parent directory if let Some(parent) = path.as_path().parent() { self.local_changedir(parent, true); // If sync is enabled update remote too - if self.browser.sync_browsing { - self.action_go_to_remote_upper_dir(); + if self.browser.sync_browsing && !block_sync { + self.action_go_to_remote_upper_dir(true); } } } @@ -171,15 +171,15 @@ impl FileTransferActivity { /// #### action_go_to_remote_upper_dir /// /// Go to upper directory on remote host - pub(super) fn action_go_to_remote_upper_dir(&mut self) { + pub(super) fn action_go_to_remote_upper_dir(&mut self, block_sync: bool) { // Get pwd let path: PathBuf = self.remote.wrkdir.clone(); // Go to parent directory if let Some(parent) = path.as_path().parent() { self.remote_changedir(parent, true); // If sync is enabled update local too - if self.browser.sync_browsing { - self.action_go_to_local_upper_dir(); + if self.browser.sync_browsing && !block_sync { + self.action_go_to_local_upper_dir(true); } } } diff --git a/src/ui/activities/filetransfer_activity/update.rs b/src/ui/activities/filetransfer_activity/update.rs index 06a16f0..71ebb67 100644 --- a/src/ui/activities/filetransfer_activity/update.rs +++ b/src/ui/activities/filetransfer_activity/update.rs @@ -73,7 +73,7 @@ impl FileTransferActivity { } (COMPONENT_EXPLORER_LOCAL, &MSG_KEY_BACKSPACE) => { // Go to previous directory - self.action_go_to_previous_local_dir(); + self.action_go_to_previous_local_dir(false); if self.browser.sync_browsing { let _ = self.update_remote_filelist(); } @@ -87,7 +87,7 @@ impl FileTransferActivity { entry = Some(e.clone()); } if let Some(entry) = entry { - if self.action_enter_local_dir(entry) { + if self.action_enter_local_dir(entry, false) { // Update file list if sync if self.browser.sync_browsing { let _ = self.update_remote_filelist(); @@ -160,7 +160,7 @@ impl FileTransferActivity { self.update_local_filelist() } (COMPONENT_EXPLORER_LOCAL, &MSG_KEY_CHAR_U) => { - self.action_go_to_local_upper_dir(); + self.action_go_to_local_upper_dir(false); if self.browser.sync_browsing { let _ = self.update_remote_filelist(); } @@ -181,7 +181,7 @@ impl FileTransferActivity { entry = Some(e.clone()); } if let Some(entry) = entry { - if self.action_enter_remote_dir(entry) { + if self.action_enter_remote_dir(entry, false) { // Update file list if sync if self.browser.sync_browsing { let _ = self.update_local_filelist(); @@ -209,7 +209,7 @@ impl FileTransferActivity { } (COMPONENT_EXPLORER_REMOTE, &MSG_KEY_BACKSPACE) => { // Go to previous directory - self.action_go_to_previous_remote_dir(); + self.action_go_to_previous_remote_dir(false); // If sync is enabled update local too if self.browser.sync_browsing { let _ = self.update_local_filelist(); @@ -263,7 +263,7 @@ impl FileTransferActivity { self.update_remote_filelist() } (COMPONENT_EXPLORER_REMOTE, &MSG_KEY_CHAR_U) => { - self.action_go_to_remote_upper_dir(); + self.action_go_to_remote_upper_dir(false); if self.browser.sync_browsing { let _ = self.update_local_filelist(); } @@ -486,8 +486,12 @@ impl FileTransferActivity { } (COMPONENT_INPUT_GOTO, Msg::OnSubmit(Payload::One(Value::Str(input)))) => { match self.tab { - FileExplorerTab::Local => self.action_change_local_dir(input.to_string()), - FileExplorerTab::Remote => self.action_change_remote_dir(input.to_string()), + FileExplorerTab::Local => { + self.action_change_local_dir(input.to_string(), false) + } + FileExplorerTab::Remote => { + self.action_change_remote_dir(input.to_string(), false) + } _ => panic!("Found tab doesn't support GOTO"), } // Umount