mirror of
https://github.com/veeso/termscp.git
synced 2026-09-28 06:51:20 -07:00
fix: issue 277 Fix a bug in the configuration page, which caused being stuck if the added SSH key was empty
This commit is contained in:
@@ -45,6 +45,7 @@ Released on
|
|||||||
- BREAKING ‼️ Kube address argument has changed; see manual!
|
- BREAKING ‼️ Kube address argument has changed; see manual!
|
||||||
- Pod and container argumets have been removed; from now on you will connect with the following syntax to the provided namespace: `/pod-name/container-name/path/to/file`
|
- Pod and container argumets have been removed; from now on you will connect with the following syntax to the provided namespace: `/pod-name/container-name/path/to/file`
|
||||||
- [Issue 279](https://github.com/veeso/termscp/issues/279): do not clear screen
|
- [Issue 279](https://github.com/veeso/termscp/issues/279): do not clear screen
|
||||||
|
- [Issue 277](https://github.com/veeso/termscp/issues/277): Fix a bug in the configuration page, which caused being stuck if the added SSH key was empty
|
||||||
|
|
||||||
## 0.14.0
|
## 0.14.0
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ impl SetupActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new ssh key
|
/// Create a new ssh key
|
||||||
pub(super) fn action_new_ssh_key(&mut self) {
|
pub(super) fn action_new_ssh_key(&mut self) -> Result<(), String> {
|
||||||
// get parameters
|
// get parameters
|
||||||
let host: String = match self.app.state(&Id::Ssh(IdSsh::SshHost)) {
|
let host: String = match self.app.state(&Id::Ssh(IdSsh::SshHost)) {
|
||||||
Ok(State::One(StateValue::String(host))) => host,
|
Ok(State::One(StateValue::String(host))) => host,
|
||||||
@@ -148,29 +148,23 @@ impl SetupActivity {
|
|||||||
// Lock ports
|
// Lock ports
|
||||||
assert!(self.app.lock_ports().is_ok());
|
assert!(self.app.lock_ports().is_ok());
|
||||||
// Write key to file
|
// Write key to file
|
||||||
match edit::edit(placeholder.as_bytes()) {
|
let res = match edit::edit(placeholder.as_bytes()) {
|
||||||
Ok(rsa_key) => {
|
Ok(rsa_key) => {
|
||||||
// Remove placeholder from `rsa_key`
|
// Remove placeholder from `rsa_key`
|
||||||
let rsa_key: String = rsa_key.as_str().replace(placeholder.as_str(), "");
|
let rsa_key: String = rsa_key.as_str().replace(placeholder.as_str(), "");
|
||||||
if rsa_key.is_empty() {
|
if rsa_key.is_empty() {
|
||||||
// Report error: empty key
|
// Report error: empty key
|
||||||
self.mount_error("SSH key is empty!");
|
Err("SSH key is empty!".to_string())
|
||||||
} else {
|
} else {
|
||||||
// Add key
|
self.add_ssh_key(host.as_str(), username.as_str(), rsa_key.as_str())
|
||||||
if let Err(err) =
|
.map_err(|e| format!("Could not create new private key: {e}"))
|
||||||
self.add_ssh_key(host.as_str(), username.as_str(), rsa_key.as_str())
|
|
||||||
{
|
|
||||||
self.mount_error(
|
|
||||||
format!("Could not create new private key: {err}").as_str(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report error
|
// Report error
|
||||||
self.mount_error(format!("Could not write private key to file: {err}").as_str());
|
Err(format!("Could not write private key to file: {err}"))
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
// Restore terminal
|
// Restore terminal
|
||||||
if let Some(ctx) = self.context.as_mut() {
|
if let Some(ctx) = self.context.as_mut() {
|
||||||
// Enter alternate mode
|
// Enter alternate mode
|
||||||
@@ -187,6 +181,8 @@ impl SetupActivity {
|
|||||||
// Unlock ports
|
// Unlock ports
|
||||||
assert!(self.app.unlock_ports().is_ok());
|
assert!(self.app.unlock_ports().is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a component and a color, save the color into the theme
|
/// Given a component and a color, save the color into the theme
|
||||||
|
|||||||
@@ -225,9 +225,14 @@ impl SetupActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SshMsg::SaveSshKey => {
|
SshMsg::SaveSshKey => {
|
||||||
self.action_new_ssh_key();
|
let res = self.action_new_ssh_key();
|
||||||
self.umount_new_ssh_key();
|
self.umount_new_ssh_key();
|
||||||
self.reload_ssh_keys();
|
match res {
|
||||||
|
Ok(_) => {
|
||||||
|
self.reload_ssh_keys();
|
||||||
|
}
|
||||||
|
Err(err) => self.mount_error(&err),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SshMsg::ShowDelSshKeyPopup => {
|
SshMsg::ShowDelSshKeyPopup => {
|
||||||
self.mount_del_ssh_key();
|
self.mount_del_ssh_key();
|
||||||
|
|||||||
Reference in New Issue
Block a user