Fixed sync browser

This commit is contained in:
veeso
2021-05-03 18:08:05 +02:00
parent 2f0b340fe0
commit a0c29d1174
2 changed files with 45 additions and 41 deletions

View File

@@ -36,12 +36,12 @@ impl FileTransferActivity {
/// ///
/// Enter a directory on local host from entry /// Enter a directory on local host from entry
/// Return true whether the directory changed /// 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 { match entry {
FsEntry::Directory(dir) => { FsEntry::Directory(dir) => {
self.remote_changedir(dir.abs_path.as_path(), true); self.local_changedir(dir.abs_path.as_path(), true);
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_change_remote_dir(dir.name.clone()); self.action_change_remote_dir(dir.name, true);
} }
true true
} }
@@ -51,10 +51,10 @@ impl FileTransferActivity {
// If symlink and is directory, point to symlink // If symlink and is directory, point to symlink
match &**symlink_entry { match &**symlink_entry {
FsEntry::Directory(dir) => { 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 // Check whether to sync
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_change_remote_dir(dir.name.clone()); self.action_change_remote_dir(dir.name.clone(), true);
} }
true true
} }
@@ -71,12 +71,12 @@ impl FileTransferActivity {
/// ///
/// Enter a directory on local host from entry /// Enter a directory on local host from entry
/// Return true whether the directory changed /// 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 { match entry {
FsEntry::Directory(dir) => { FsEntry::Directory(dir) => {
self.local_changedir(dir.abs_path.as_path(), true); self.remote_changedir(dir.abs_path.as_path(), true);
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_change_local_dir(dir.name.clone()); self.action_change_local_dir(dir.name, true);
} }
true true
} }
@@ -86,10 +86,10 @@ impl FileTransferActivity {
// If symlink and is directory, point to symlink // If symlink and is directory, point to symlink
match &**symlink_entry { match &**symlink_entry {
FsEntry::Directory(dir) => { 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 // Check whether to sync
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_change_local_dir(dir.name.clone()); self.action_change_local_dir(dir.name.clone(), true);
} }
true true
} }
@@ -105,36 +105,36 @@ impl FileTransferActivity {
/// ### action_change_local_dir /// ### action_change_local_dir
/// ///
/// Change local directory reading value from input /// 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()); let dir_path: PathBuf = self.local_to_abs_path(PathBuf::from(input.as_str()).as_path());
self.local_changedir(dir_path.as_path(), true); self.local_changedir(dir_path.as_path(), true);
// Check whether to sync // Check whether to sync
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_change_remote_dir(input); self.action_change_remote_dir(input, true);
} }
} }
/// ### action_change_remote_dir /// ### action_change_remote_dir
/// ///
/// Change remote directory reading value from input /// 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()); let dir_path: PathBuf = self.remote_to_abs_path(PathBuf::from(input.as_str()).as_path());
self.remote_changedir(dir_path.as_path(), true); self.remote_changedir(dir_path.as_path(), true);
// Check whether to sync // Check whether to sync
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_change_local_dir(input); self.action_change_local_dir(input, true);
} }
} }
/// ### action_go_to_previous_local_dir /// ### action_go_to_previous_local_dir
/// ///
/// Go to previous directory from localhost /// 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() { if let Some(d) = self.local.popd() {
self.local_changedir(d.as_path(), false); self.local_changedir(d.as_path(), false);
// Check whether to sync // Check whether to sync
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_go_to_previous_remote_dir(); self.action_go_to_previous_remote_dir(true);
} }
} }
} }
@@ -142,12 +142,12 @@ impl FileTransferActivity {
/// ### action_go_to_previous_remote_dir /// ### action_go_to_previous_remote_dir
/// ///
/// Go to previous directory from remote host /// Go to previous directory from remote host
pub(super) fn action_go_to_previous_remote_dir(&mut self) { pub(super) fn action_go_to_previous_remote_dir(&mut self, block_sync: bool) {
if let Some(d) = self.local.popd() { if let Some(d) = self.remote.popd() {
self.remote_changedir(d.as_path(), false); self.remote_changedir(d.as_path(), false);
// Check whether to sync // Check whether to sync
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_go_to_previous_local_dir(); self.action_go_to_previous_local_dir(true);
} }
} }
} }
@@ -155,15 +155,15 @@ impl FileTransferActivity {
/// ### action_go_to_local_upper_dir /// ### action_go_to_local_upper_dir
/// ///
/// Go to upper directory on local host /// 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 // Get pwd
let path: PathBuf = self.local.wrkdir.clone(); let path: PathBuf = self.local.wrkdir.clone();
// Go to parent directory // Go to parent directory
if let Some(parent) = path.as_path().parent() { if let Some(parent) = path.as_path().parent() {
self.local_changedir(parent, true); self.local_changedir(parent, true);
// If sync is enabled update remote too // If sync is enabled update remote too
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_go_to_remote_upper_dir(); self.action_go_to_remote_upper_dir(true);
} }
} }
} }
@@ -171,15 +171,15 @@ impl FileTransferActivity {
/// #### action_go_to_remote_upper_dir /// #### action_go_to_remote_upper_dir
/// ///
/// Go to upper directory on remote host /// 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 // Get pwd
let path: PathBuf = self.remote.wrkdir.clone(); let path: PathBuf = self.remote.wrkdir.clone();
// Go to parent directory // Go to parent directory
if let Some(parent) = path.as_path().parent() { if let Some(parent) = path.as_path().parent() {
self.remote_changedir(parent, true); self.remote_changedir(parent, true);
// If sync is enabled update local too // If sync is enabled update local too
if self.browser.sync_browsing { if self.browser.sync_browsing && !block_sync {
self.action_go_to_local_upper_dir(); self.action_go_to_local_upper_dir(true);
} }
} }
} }

View File

@@ -73,7 +73,7 @@ impl FileTransferActivity {
} }
(COMPONENT_EXPLORER_LOCAL, &MSG_KEY_BACKSPACE) => { (COMPONENT_EXPLORER_LOCAL, &MSG_KEY_BACKSPACE) => {
// Go to previous directory // Go to previous directory
self.action_go_to_previous_local_dir(); self.action_go_to_previous_local_dir(false);
if self.browser.sync_browsing { if self.browser.sync_browsing {
let _ = self.update_remote_filelist(); let _ = self.update_remote_filelist();
} }
@@ -87,7 +87,7 @@ impl FileTransferActivity {
entry = Some(e.clone()); entry = Some(e.clone());
} }
if let Some(entry) = entry { 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 // Update file list if sync
if self.browser.sync_browsing { if self.browser.sync_browsing {
let _ = self.update_remote_filelist(); let _ = self.update_remote_filelist();
@@ -160,7 +160,7 @@ impl FileTransferActivity {
self.update_local_filelist() self.update_local_filelist()
} }
(COMPONENT_EXPLORER_LOCAL, &MSG_KEY_CHAR_U) => { (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 { if self.browser.sync_browsing {
let _ = self.update_remote_filelist(); let _ = self.update_remote_filelist();
} }
@@ -181,7 +181,7 @@ impl FileTransferActivity {
entry = Some(e.clone()); entry = Some(e.clone());
} }
if let Some(entry) = entry { 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 // Update file list if sync
if self.browser.sync_browsing { if self.browser.sync_browsing {
let _ = self.update_local_filelist(); let _ = self.update_local_filelist();
@@ -209,7 +209,7 @@ impl FileTransferActivity {
} }
(COMPONENT_EXPLORER_REMOTE, &MSG_KEY_BACKSPACE) => { (COMPONENT_EXPLORER_REMOTE, &MSG_KEY_BACKSPACE) => {
// Go to previous directory // 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 sync is enabled update local too
if self.browser.sync_browsing { if self.browser.sync_browsing {
let _ = self.update_local_filelist(); let _ = self.update_local_filelist();
@@ -263,7 +263,7 @@ impl FileTransferActivity {
self.update_remote_filelist() self.update_remote_filelist()
} }
(COMPONENT_EXPLORER_REMOTE, &MSG_KEY_CHAR_U) => { (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 { if self.browser.sync_browsing {
let _ = self.update_local_filelist(); let _ = self.update_local_filelist();
} }
@@ -486,8 +486,12 @@ impl FileTransferActivity {
} }
(COMPONENT_INPUT_GOTO, Msg::OnSubmit(Payload::One(Value::Str(input)))) => { (COMPONENT_INPUT_GOTO, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_change_local_dir(input.to_string()), FileExplorerTab::Local => {
FileExplorerTab::Remote => self.action_change_remote_dir(input.to_string()), 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"), _ => panic!("Found tab doesn't support GOTO"),
} }
// Umount // Umount