GOTO for remote

This commit is contained in:
ChristianVisintin
2020-11-29 16:18:50 +01:00
parent b300f510b8
commit a843a5a0de

View File

@@ -1167,6 +1167,10 @@ impl FileTransferActivity {
///
/// Callback for GOTO command
fn callback_change_directory(&mut self, input: String) {
match self.tab {
FileExplorerTab::Local => {
// Get current directory
let prev_dir: PathBuf = self.context.as_ref().unwrap().local.pwd();
match self
.context
.as_mut()
@@ -1181,7 +1185,55 @@ impl FileTransferActivity {
format!("Could not change working directory: {}", err),
));
}
Ok(_) => self.local.files = self.context.as_ref().unwrap().local.list_dir(), // Update files
Ok(_) => {
// Push previous directory to stack
self.local.pushd(prev_dir.as_path());
// Update files
self.local.files = self.context.as_ref().unwrap().local.list_dir()
}
}
}
FileExplorerTab::Remote => {
// Get current directory
match self.client.pwd() {
Ok(prev_dir) => {
// Change directory
match self
.client
.change_dir(PathBuf::from(input.as_str()).as_path())
{
Ok(_) => self.remote.pushd(prev_dir.as_path()), // Push prev_dir to stack
Err(err) => {
// Report err
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not change working directory: {}", err),
));
}
}
// Update files
match self
.client
.list_dir(PathBuf::from(input.as_str()).as_path())
{
Ok(files) => self.remote.files = files,
Err(err) => {
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not scan remote directory: {}", err),
));
}
}
}
Err(err) => {
// Report err
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not change working directory: {}", err),
));
}
}
}
}
}