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
/// 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);
}
}
}