mirror of
https://github.com/veeso/termscp.git
synced 2026-09-26 22:11:26 -07:00
lint
This commit is contained in:
@@ -78,7 +78,7 @@ impl ActivityManager {
|
|||||||
params.set_default_secret(password.to_string());
|
params.set_default_secret(password.to_string());
|
||||||
} else {
|
} else {
|
||||||
match tty::read_secret_from_tty("Password: ") {
|
match tty::read_secret_from_tty("Password: ") {
|
||||||
Err(err) => return Err(format!("Could not read password: {}", err)),
|
Err(err) => return Err(format!("Could not read password: {err}")),
|
||||||
Ok(Some(secret)) => {
|
Ok(Some(secret)) => {
|
||||||
debug!(
|
debug!(
|
||||||
"Read password from tty: {}",
|
"Read password from tty: {}",
|
||||||
@@ -105,8 +105,7 @@ impl ActivityManager {
|
|||||||
if let Some(bookmarks_client) = self.context.as_mut().unwrap().bookmarks_client_mut() {
|
if let Some(bookmarks_client) = self.context.as_mut().unwrap().bookmarks_client_mut() {
|
||||||
match bookmarks_client.get_bookmark(bookmark_name) {
|
match bookmarks_client.get_bookmark(bookmark_name) {
|
||||||
None => Err(format!(
|
None => Err(format!(
|
||||||
r#"Could not resolve bookmark name: "{}" no such bookmark"#,
|
r#"Could not resolve bookmark name: "{bookmark_name}" no such bookmark"#
|
||||||
bookmark_name
|
|
||||||
)),
|
)),
|
||||||
Some(params) => self.set_filetransfer_params(params, password),
|
Some(params) => self.set_filetransfer_params(params, password),
|
||||||
}
|
}
|
||||||
@@ -217,7 +216,7 @@ impl ActivityManager {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Set error in context
|
// Set error in context
|
||||||
error!("Failed to initialize localhost: {}", err);
|
error!("Failed to initialize localhost: {}", err);
|
||||||
ctx.set_error(format!("Could not initialize localhost: {}", err));
|
ctx.set_error(format!("Could not initialize localhost: {err}"));
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -325,7 +324,7 @@ impl ActivityManager {
|
|||||||
environment::get_config_paths(config_dir.as_path());
|
environment::get_config_paths(config_dir.as_path());
|
||||||
match ConfigClient::new(config_path.as_path(), ssh_dir.as_path()) {
|
match ConfigClient::new(config_path.as_path(), ssh_dir.as_path()) {
|
||||||
Ok(cli) => Ok(cli),
|
Ok(cli) => Ok(cli),
|
||||||
Err(err) => Err(format!("Could not read configuration: {}", err)),
|
Err(err) => Err(format!("Could not read configuration: {err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => Err(String::from(
|
None => Err(String::from(
|
||||||
@@ -334,8 +333,7 @@ impl ActivityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => Err(format!(
|
Err(err) => Err(format!(
|
||||||
"Could not initialize configuration directory: {}",
|
"Could not initialize configuration directory: {err}"
|
||||||
err
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -127,12 +127,12 @@ mod tests {
|
|||||||
fn test_config_serialization_errors() {
|
fn test_config_serialization_errors() {
|
||||||
let error: SerializerError = SerializerError::new(SerializerErrorKind::Syntax);
|
let error: SerializerError = SerializerError::new(SerializerErrorKind::Syntax);
|
||||||
assert!(error.msg.is_none());
|
assert!(error.msg.is_none());
|
||||||
assert_eq!(format!("{}", error), String::from("Syntax error"));
|
assert_eq!(format!("{error}"), String::from("Syntax error"));
|
||||||
let error: SerializerError =
|
let error: SerializerError =
|
||||||
SerializerError::new_ex(SerializerErrorKind::Syntax, String::from("bad syntax"));
|
SerializerError::new_ex(SerializerErrorKind::Syntax, String::from("bad syntax"));
|
||||||
assert!(error.msg.is_some());
|
assert!(error.msg.is_some());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", error),
|
format!("{error}"),
|
||||||
String::from("Syntax error (bad syntax)")
|
String::from("Syntax error (bad syntax)")
|
||||||
);
|
);
|
||||||
// Fmt
|
// Fmt
|
||||||
@@ -159,7 +159,7 @@ mod tests {
|
|||||||
fn test_config_serialization_params_deserialize_ok() {
|
fn test_config_serialization_params_deserialize_ok() {
|
||||||
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks_params();
|
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks_params();
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
// Parse
|
// Parse
|
||||||
let cfg = deserialize(Box::new(toml_file));
|
let cfg = deserialize(Box::new(toml_file));
|
||||||
assert!(cfg.is_ok());
|
assert!(cfg.is_ok());
|
||||||
@@ -209,7 +209,7 @@ mod tests {
|
|||||||
fn test_config_serialization_params_deserialize_ok_no_opts() {
|
fn test_config_serialization_params_deserialize_ok_no_opts() {
|
||||||
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks_params_no_opts();
|
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks_params_no_opts();
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
// Parse
|
// Parse
|
||||||
let cfg = deserialize(Box::new(toml_file));
|
let cfg = deserialize(Box::new(toml_file));
|
||||||
assert!(cfg.is_ok());
|
assert!(cfg.is_ok());
|
||||||
@@ -249,7 +249,7 @@ mod tests {
|
|||||||
fn test_config_serialization_params_deserialize_nok() {
|
fn test_config_serialization_params_deserialize_nok() {
|
||||||
let toml_file: tempfile::NamedTempFile = create_bad_toml_bookmarks_params();
|
let toml_file: tempfile::NamedTempFile = create_bad_toml_bookmarks_params();
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
// Parse
|
// Parse
|
||||||
assert!(deserialize::<UserConfig>(Box::new(toml_file)).is_err());
|
assert!(deserialize::<UserConfig>(Box::new(toml_file)).is_err());
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ mod tests {
|
|||||||
assert!(serialize(&cfg, writer).is_ok());
|
assert!(serialize(&cfg, writer).is_ok());
|
||||||
// Reload configuration and check if it's ok
|
// Reload configuration and check if it's ok
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
assert!(deserialize::<UserConfig>(Box::new(toml_file)).is_ok());
|
assert!(deserialize::<UserConfig>(Box::new(toml_file)).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ mod tests {
|
|||||||
fn test_config_serializer_bookmarks_serializer_deserialize_ok() {
|
fn test_config_serializer_bookmarks_serializer_deserialize_ok() {
|
||||||
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks();
|
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks();
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
// Parse
|
// Parse
|
||||||
let hosts = deserialize(Box::new(toml_file));
|
let hosts = deserialize(Box::new(toml_file));
|
||||||
assert!(hosts.is_ok());
|
assert!(hosts.is_ok());
|
||||||
@@ -412,7 +412,7 @@ mod tests {
|
|||||||
fn test_config_serializer_bookmarks_serializer_deserialize_nok() {
|
fn test_config_serializer_bookmarks_serializer_deserialize_nok() {
|
||||||
let toml_file: tempfile::NamedTempFile = create_bad_toml_bookmarks();
|
let toml_file: tempfile::NamedTempFile = create_bad_toml_bookmarks();
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
// Parse
|
// Parse
|
||||||
assert!(deserialize::<UserHosts>(Box::new(toml_file)).is_err());
|
assert!(deserialize::<UserHosts>(Box::new(toml_file)).is_err());
|
||||||
}
|
}
|
||||||
@@ -500,11 +500,11 @@ mod tests {
|
|||||||
fn test_config_serialization_theme_deserialize() {
|
fn test_config_serialization_theme_deserialize() {
|
||||||
let toml_file = create_good_toml_theme();
|
let toml_file = create_good_toml_theme();
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
assert!(deserialize::<Theme>(Box::new(toml_file)).is_ok());
|
assert!(deserialize::<Theme>(Box::new(toml_file)).is_ok());
|
||||||
let toml_file = create_bad_toml_theme();
|
let toml_file = create_bad_toml_theme();
|
||||||
toml_file.as_file().sync_all().unwrap();
|
toml_file.as_file().sync_all().unwrap();
|
||||||
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
|
toml_file.as_file().rewind().unwrap();
|
||||||
assert!(deserialize::<Theme>(Box::new(toml_file)).is_err());
|
assert!(deserialize::<Theme>(Box::new(toml_file)).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ impl Formatter {
|
|||||||
name.push('/');
|
name.push('/');
|
||||||
}
|
}
|
||||||
// Add to cur str, prefix and the key value
|
// Add to cur str, prefix and the key value
|
||||||
format!("{}{}{:0width$}", cur_str, prefix, name, width = file_len)
|
format!("{cur_str}{prefix}{name:0file_len$}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format path
|
/// Format path
|
||||||
@@ -347,7 +347,7 @@ impl Formatter {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
// Add to cur str, prefix and the key value
|
// Add to cur str, prefix and the key value
|
||||||
format!("{}{}{:10}", cur_str, prefix, pex)
|
format!("{cur_str}{prefix}{pex:10}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format file size
|
/// Format file size
|
||||||
@@ -363,7 +363,7 @@ impl Formatter {
|
|||||||
// Get byte size
|
// Get byte size
|
||||||
let size: ByteSize = ByteSize(fsentry.metadata().size);
|
let size: ByteSize = ByteSize(fsentry.metadata().size);
|
||||||
// Add to cur str, prefix and the key value
|
// Add to cur str, prefix and the key value
|
||||||
format!("{}{}{:10}", cur_str, prefix, size)
|
format!("{cur_str}{prefix}{size:10}")
|
||||||
} else if fsentry.metadata().symlink.is_some() {
|
} else if fsentry.metadata().symlink.is_some() {
|
||||||
let size = ByteSize(
|
let size = ByteSize(
|
||||||
fsentry
|
fsentry
|
||||||
@@ -374,10 +374,10 @@ impl Formatter {
|
|||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.len() as u64,
|
.len() as u64,
|
||||||
);
|
);
|
||||||
format!("{}{}{:10}", cur_str, prefix, size)
|
format!("{cur_str}{prefix}{size:10}")
|
||||||
} else {
|
} else {
|
||||||
// Add to cur str, prefix and the key value
|
// Add to cur str, prefix and the key value
|
||||||
format!("{}{} ", cur_str, prefix)
|
format!("{cur_str}{prefix} ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ impl Formatter {
|
|||||||
};
|
};
|
||||||
// Replace `FMT_KEY_NAME` with name
|
// Replace `FMT_KEY_NAME` with name
|
||||||
match fsentry.metadata().symlink.as_deref() {
|
match fsentry.metadata().symlink.as_deref() {
|
||||||
None => format!("{}{} ", cur_str, prefix),
|
None => format!("{cur_str}{prefix} "),
|
||||||
Some(p) => format!(
|
Some(p) => format!(
|
||||||
"{}{}-> {:0width$}",
|
"{}{}-> {:0width$}",
|
||||||
cur_str,
|
cur_str,
|
||||||
@@ -432,7 +432,7 @@ impl Formatter {
|
|||||||
None => 0.to_string(),
|
None => 0.to_string(),
|
||||||
};
|
};
|
||||||
// Add to cur str, prefix and the key value
|
// Add to cur str, prefix and the key value
|
||||||
format!("{}{}{:12}", cur_str, prefix, username)
|
format!("{cur_str}{prefix}{username:12}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fallback function in case the format key is unknown
|
/// Fallback function in case the format key is unknown
|
||||||
@@ -446,7 +446,7 @@ impl Formatter {
|
|||||||
_fmt_extra: Option<&String>,
|
_fmt_extra: Option<&String>,
|
||||||
) -> String {
|
) -> String {
|
||||||
// Add to cur str and prefix
|
// Add to cur str and prefix
|
||||||
format!("{}{}", cur_str, prefix)
|
format!("{cur_str}{prefix}")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
@@ -1008,6 +1008,6 @@ mod tests {
|
|||||||
_fmt_len: Option<&usize>,
|
_fmt_len: Option<&usize>,
|
||||||
_fmt_extra: Option<&String>,
|
_fmt_extra: Option<&String>,
|
||||||
) -> String {
|
) -> String {
|
||||||
format!("{}{}A", cur_str, prefix)
|
format!("{cur_str}{prefix}A")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ impl Builder {
|
|||||||
(protocol, params) => {
|
(protocol, params) => {
|
||||||
error!("Invalid params for protocol '{:?}'", protocol);
|
error!("Invalid params for protocol '{:?}'", protocol);
|
||||||
panic!(
|
panic!(
|
||||||
"Invalid protocol '{:?}' with parameters of type {:?}",
|
"Invalid protocol '{protocol:?}' with parameters of type {params:?}"
|
||||||
protocol, params
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1099,7 +1099,7 @@ mod tests {
|
|||||||
Path::new("/tmp"),
|
Path::new("/tmp"),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", err),
|
format!("{err}"),
|
||||||
String::from("Could not create file: address in use (/tmp)"),
|
String::from("Could not create file: address in use (/tmp)"),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
+11
-12
@@ -42,13 +42,13 @@ fn main() {
|
|||||||
let run_opts: RunOpts = match parse_args(args) {
|
let run_opts: RunOpts = match parse_args(args) {
|
||||||
Ok(opts) => opts,
|
Ok(opts) => opts,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("{}", err);
|
eprintln!("{err}");
|
||||||
std::process::exit(255);
|
std::process::exit(255);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Setup logging
|
// Setup logging
|
||||||
if let Err(err) = logging::init(run_opts.log_level) {
|
if let Err(err) = logging::init(run_opts.log_level) {
|
||||||
eprintln!("Failed to initialize logging: {}", err);
|
eprintln!("Failed to initialize logging: {err}");
|
||||||
}
|
}
|
||||||
info!("termscp {} started!", TERMSCP_VERSION);
|
info!("termscp {} started!", TERMSCP_VERSION);
|
||||||
// Run
|
// Run
|
||||||
@@ -67,8 +67,7 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
|||||||
// Version
|
// Version
|
||||||
if args.version {
|
if args.version {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"termscp - {} - Developed by {}",
|
"termscp - {TERMSCP_VERSION} - Developed by {TERMSCP_AUTHORS}",
|
||||||
TERMSCP_VERSION, TERMSCP_AUTHORS,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
// Setup activity?
|
// Setup activity?
|
||||||
@@ -108,7 +107,7 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
|||||||
// Change working directory if local dir is set
|
// Change working directory if local dir is set
|
||||||
let localdir: PathBuf = PathBuf::from(localdir);
|
let localdir: PathBuf = PathBuf::from(localdir);
|
||||||
if let Err(err) = env::set_current_dir(localdir.as_path()) {
|
if let Err(err) = env::set_current_dir(localdir.as_path()) {
|
||||||
return Err(format!("Bad working directory argument: {}", err));
|
return Err(format!("Bad working directory argument: {err}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(run_opts)
|
Ok(run_opts)
|
||||||
@@ -134,7 +133,7 @@ fn parse_address_arg(args: &Args) -> Result<Remote, String> {
|
|||||||
|
|
||||||
/// Parse remote address
|
/// Parse remote address
|
||||||
fn parse_remote_address(remote: &str) -> Result<FileTransferParams, String> {
|
fn parse_remote_address(remote: &str) -> Result<FileTransferParams, String> {
|
||||||
utils::parser::parse_remote_opt(remote).map_err(|e| format!("Bad address option: {}", e))
|
utils::parser::parse_remote_opt(remote).map_err(|e| format!("Bad address option: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### run
|
/// ### run
|
||||||
@@ -148,17 +147,17 @@ fn run(run_opts: RunOpts) -> i32 {
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("{}", err);
|
eprintln!("{err}");
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Task::InstallUpdate => match support::install_update() {
|
Task::InstallUpdate => match support::install_update() {
|
||||||
Ok(msg) => {
|
Ok(msg) => {
|
||||||
println!("{}", msg);
|
println!("{msg}");
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Could not install update: {}", err);
|
eprintln!("Could not install update: {err}");
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -173,7 +172,7 @@ fn run(run_opts: RunOpts) -> i32 {
|
|||||||
match ActivityManager::new(wrkdir.as_path(), run_opts.ticks) {
|
match ActivityManager::new(wrkdir.as_path(), run_opts.ticks) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Could not start activity manager: {}", err);
|
eprintln!("Could not start activity manager: {err}");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -181,13 +180,13 @@ fn run(run_opts: RunOpts) -> i32 {
|
|||||||
match run_opts.remote {
|
match run_opts.remote {
|
||||||
Remote::Bookmark(BookmarkParams { name, password }) => {
|
Remote::Bookmark(BookmarkParams { name, password }) => {
|
||||||
if let Err(err) = manager.resolve_bookmark_name(&name, password.as_deref()) {
|
if let Err(err) = manager.resolve_bookmark_name(&name, password.as_deref()) {
|
||||||
eprintln!("{}", err);
|
eprintln!("{err}");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Remote::Host(HostParams { params, password }) => {
|
Remote::Host(HostParams { params, password }) => {
|
||||||
if let Err(err) = manager.set_filetransfer_params(params, password.as_deref()) {
|
if let Err(err) = manager.set_filetransfer_params(params, password.as_deref()) {
|
||||||
eprintln!("{}", err);
|
eprintln!("{err}");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -23,7 +23,7 @@ pub fn import_theme(p: &Path) -> Result<(), String> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
// Validate theme file
|
// Validate theme file
|
||||||
ThemeProvider::new(p).map_err(|e| format!("Invalid theme error: {}", e))?;
|
ThemeProvider::new(p).map_err(|e| format!("Invalid theme error: {e}"))?;
|
||||||
// get config dir
|
// get config dir
|
||||||
let cfg_dir: PathBuf = get_config_dir()?;
|
let cfg_dir: PathBuf = get_config_dir()?;
|
||||||
// Get theme directory
|
// Get theme directory
|
||||||
@@ -31,7 +31,7 @@ pub fn import_theme(p: &Path) -> Result<(), String> {
|
|||||||
// Copy theme to theme_dir
|
// Copy theme to theme_dir
|
||||||
fs::copy(p, theme_file.as_path())
|
fs::copy(p, theme_file.as_path())
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(|e| format!("Could not import theme: {}", e))
|
.map_err(|e| format!("Could not import theme: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### install_update
|
/// ### install_update
|
||||||
@@ -51,7 +51,7 @@ pub fn install_update() -> Result<String, String> {
|
|||||||
{
|
{
|
||||||
Notification::update_installed(v.as_str());
|
Notification::update_installed(v.as_str());
|
||||||
}
|
}
|
||||||
Ok(format!("termscp has been updated to version {}", v))
|
Ok(format!("termscp has been updated to version {v}"))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if get_config_client()
|
if get_config_client()
|
||||||
@@ -75,8 +75,7 @@ fn get_config_dir() -> Result<PathBuf, String> {
|
|||||||
"Your system doesn't provide a configuration directory",
|
"Your system doesn't provide a configuration directory",
|
||||||
)),
|
)),
|
||||||
Err(err) => Err(format!(
|
Err(err) => Err(format!(
|
||||||
"Could not initialize configuration directory: {}",
|
"Could not initialize configuration directory: {err}"
|
||||||
err
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ impl BookmarksClient {
|
|||||||
error!("Failed to set new key into storage: {}", e);
|
error!("Failed to set new key into storage: {}", e);
|
||||||
return Err(SerializerError::new_ex(
|
return Err(SerializerError::new_ex(
|
||||||
SerializerErrorKind::Io,
|
SerializerErrorKind::Io,
|
||||||
format!("Could not write key to storage: {}", e),
|
format!("Could not write key to storage: {e}"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
// Return key
|
// Return key
|
||||||
@@ -98,7 +98,7 @@ impl BookmarksClient {
|
|||||||
error!("Failed to get key from storage: {}", e);
|
error!("Failed to get key from storage: {}", e);
|
||||||
return Err(SerializerError::new_ex(
|
return Err(SerializerError::new_ex(
|
||||||
SerializerErrorKind::Io,
|
SerializerErrorKind::Io,
|
||||||
format!("Could not get key from storage: {}", e),
|
format!("Could not get key from storage: {e}"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ impl ConfigClient {
|
|||||||
// Get key path
|
// Get key path
|
||||||
let ssh_key_path: PathBuf = {
|
let ssh_key_path: PathBuf = {
|
||||||
let mut p: PathBuf = self.ssh_key_dir.clone();
|
let mut p: PathBuf = self.ssh_key_dir.clone();
|
||||||
p.push(format!("{}.key", host_name));
|
p.push(format!("{host_name}.key"));
|
||||||
p
|
p
|
||||||
};
|
};
|
||||||
info!(
|
info!(
|
||||||
@@ -390,7 +390,7 @@ impl ConfigClient {
|
|||||||
/// Hosts are saved as `username@host` into configuration.
|
/// Hosts are saved as `username@host` into configuration.
|
||||||
/// This method creates the key name, starting from host and username
|
/// This method creates the key name, starting from host and username
|
||||||
fn make_ssh_host_key(host: &str, username: &str) -> String {
|
fn make_ssh_host_key(host: &str, username: &str) -> String {
|
||||||
format!("{}@{}", username, host)
|
format!("{username}@{host}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get ssh tokens starting from ssh host key
|
/// Get ssh tokens starting from ssh host key
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl FileStorage {
|
|||||||
/// Make file path for key file from `dir_path` and the application id
|
/// Make file path for key file from `dir_path` and the application id
|
||||||
fn make_file_path(&self, storage_id: &str) -> PathBuf {
|
fn make_file_path(&self, storage_id: &str) -> PathBuf {
|
||||||
let mut p: PathBuf = self.dir_path.clone();
|
let mut p: PathBuf = self.dir_path.clone();
|
||||||
let file_name = format!(".{}.key", storage_id);
|
let file_name = format!(".{storage_id}.key");
|
||||||
p.push(file_name);
|
p.push(file_name);
|
||||||
p
|
p
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub fn init(level: LogLevel) -> Result<(), String> {
|
|||||||
let config = ConfigBuilder::new().set_time_format_rfc3339().build();
|
let config = ConfigBuilder::new().set_time_format_rfc3339().build();
|
||||||
// Make logger
|
// Make logger
|
||||||
WriteLogger::init(level, config, file)
|
WriteLogger::init(level, config, file)
|
||||||
.map_err(|e| format!("Failed to initialize logger: {}", e))
|
.map_err(|e| format!("Failed to initialize logger: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl SshKeyStorage {
|
|||||||
|
|
||||||
/// Make mapkey from host and username
|
/// Make mapkey from host and username
|
||||||
fn make_mapkey(host: &str, username: &str) -> String {
|
fn make_mapkey(host: &str, username: &str) -> String {
|
||||||
format!("{}@{}", username, host)
|
format!("{username}@{host}")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -46,11 +46,11 @@ impl SshKeyStorage {
|
|||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
|
||||||
let mut reader = File::open(path)
|
let mut reader = File::open(path)
|
||||||
.map_err(|e| format!("failed to open {}: {}", path, e))
|
.map_err(|e| format!("failed to open {path}: {e}"))
|
||||||
.map(BufReader::new)?;
|
.map(BufReader::new)?;
|
||||||
SshConfig::default()
|
SshConfig::default()
|
||||||
.parse(&mut reader)
|
.parse(&mut reader)
|
||||||
.map_err(|e| format!("Failed to parse ssh2 config: {}", e))
|
.map_err(|e| format!("Failed to parse ssh2 config: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolve host via termscp ssh keys storage
|
/// Resolve host via termscp ssh keys storage
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ impl AuthActivity {
|
|||||||
fn write_bookmarks(&mut self) {
|
fn write_bookmarks(&mut self) {
|
||||||
if let Some(bookmarks_cli) = self.bookmarks_client() {
|
if let Some(bookmarks_cli) = self.bookmarks_client() {
|
||||||
if let Err(err) = bookmarks_cli.write_bookmarks() {
|
if let Err(err) = bookmarks_cli.write_bookmarks() {
|
||||||
self.mount_error(format!("Could not write bookmarks: {}", err).as_str());
|
self.mount_error(format!("Could not write bookmarks: {err}").as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ impl AuthActivity {
|
|||||||
// Report error
|
// Report error
|
||||||
error!("Failed to get latest version: {}", err);
|
error!("Failed to get latest version: {}", err);
|
||||||
self.mount_error(
|
self.mount_error(
|
||||||
format!("Could not check for new updates: {}", err).as_str(),
|
format!("Could not check for new updates: {err}").as_str(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,13 +136,13 @@ impl AuthActivity {
|
|||||||
if self.config().get_notifications() {
|
if self.config().get_notifications() {
|
||||||
Notification::update_installed(ver.as_str());
|
Notification::update_installed(ver.as_str());
|
||||||
}
|
}
|
||||||
self.mount_info(format!("termscp has been updated to version {}!", ver))
|
self.mount_info(format!("termscp has been updated to version {ver}!"))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if self.config().get_notifications() {
|
if self.config().get_notifications() {
|
||||||
Notification::update_failed(err.to_string());
|
Notification::update_failed(err.to_string());
|
||||||
}
|
}
|
||||||
self.mount_error(format!("Could not install update: {}", err))
|
self.mount_error(format!("Could not install update: {err}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ impl Activity for AuthActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.mount_error(format!("Application error: {}", err));
|
self.mount_error(format!("Application error: {err}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// View
|
// View
|
||||||
|
|||||||
@@ -881,7 +881,7 @@ impl AuthActivity {
|
|||||||
/// Format bookmark to display on ui
|
/// Format bookmark to display on ui
|
||||||
fn fmt_bookmark(name: &str, b: FileTransferParams) -> String {
|
fn fmt_bookmark(name: &str, b: FileTransferParams) -> String {
|
||||||
let addr: String = Self::fmt_recent(b);
|
let addr: String = Self::fmt_recent(b);
|
||||||
format!("{} ({})", name, addr)
|
format!("{name} ({addr})")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format recent connection to display on ui
|
/// Format recent connection to display on ui
|
||||||
@@ -890,7 +890,7 @@ impl AuthActivity {
|
|||||||
match b.params {
|
match b.params {
|
||||||
ProtocolParams::AwsS3(s3) => {
|
ProtocolParams::AwsS3(s3) => {
|
||||||
let profile: String = match s3.profile {
|
let profile: String = match s3.profile {
|
||||||
Some(p) => format!("[{}]", p),
|
Some(p) => format!("[{p}]"),
|
||||||
None => String::default(),
|
None => String::default(),
|
||||||
};
|
};
|
||||||
format!(
|
format!(
|
||||||
@@ -905,7 +905,7 @@ impl AuthActivity {
|
|||||||
ProtocolParams::Generic(params) => {
|
ProtocolParams::Generic(params) => {
|
||||||
let username: String = match params.username {
|
let username: String = match params.username {
|
||||||
None => String::default(),
|
None => String::default(),
|
||||||
Some(u) => format!("{}@", u),
|
Some(u) => format!("{u}@"),
|
||||||
};
|
};
|
||||||
format!(
|
format!(
|
||||||
"{}://{}{}:{}",
|
"{}://{}{}:{}",
|
||||||
|
|||||||
@@ -159,8 +159,7 @@ impl FileTransferActivity {
|
|||||||
self.log(
|
self.log(
|
||||||
LogLevel::Warn,
|
LogLevel::Warn,
|
||||||
format!(
|
format!(
|
||||||
"Refused to create '{}'; synchronized browsing disabled",
|
"Refused to create '{name}'; synchronized browsing disabled"
|
||||||
name
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
self.browser.toggle_sync_browsing();
|
self.browser.toggle_sync_browsing();
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Copy failed: could not create temporary directory: {}", err),
|
format!("Copy failed: could not create temporary directory: {err}"),
|
||||||
);
|
);
|
||||||
return Err(err.to_string());
|
return Err(err.to_string());
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ impl FileTransferActivity {
|
|||||||
{
|
{
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Copy failed: failed to download file: {}", err),
|
format!("Copy failed: failed to download file: {err}"),
|
||||||
);
|
);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ impl FileTransferActivity {
|
|||||||
) {
|
) {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Copy failed: failed to send file: {}", err),
|
format!("Copy failed: failed to send file: {err}"),
|
||||||
);
|
);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Copy failed: could not create temporary file: {}", err),
|
format!("Copy failed: could not create temporary file: {err}"),
|
||||||
);
|
);
|
||||||
return Err(String::from("Could not create temporary file"));
|
return Err(String::from("Could not create temporary file"));
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ impl FileTransferActivity {
|
|||||||
{
|
{
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Copy failed: could not download to temporary file: {}", err),
|
format!("Copy failed: could not download to temporary file: {err}"),
|
||||||
);
|
);
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(format!("Could not read file: {}", err));
|
return Err(format!("Could not read file: {err}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(format!("Could not read file: {}", err));
|
return Err(format!("Could not read file: {err}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Put input mode back to normal
|
// Put input mode back to normal
|
||||||
@@ -98,7 +98,7 @@ impl FileTransferActivity {
|
|||||||
path.display()
|
path.display()
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Err(err) => return Err(format!("Could not open editor: {}", err)),
|
Err(err) => return Err(format!("Could not open editor: {err}")),
|
||||||
}
|
}
|
||||||
if let Some(ctx) = self.context.as_mut() {
|
if let Some(ctx) = self.context.as_mut() {
|
||||||
// Enter alternate mode
|
// Enter alternate mode
|
||||||
@@ -134,7 +134,7 @@ impl FileTransferActivity {
|
|||||||
tmpfile.as_path(),
|
tmpfile.as_path(),
|
||||||
Some(file_name.clone()),
|
Some(file_name.clone()),
|
||||||
) {
|
) {
|
||||||
return Err(format!("Could not open file {}: {}", file_name, err));
|
return Err(format!("Could not open file {file_name}: {err}"));
|
||||||
}
|
}
|
||||||
// Get current file modification time
|
// Get current file modification time
|
||||||
let prev_mtime: SystemTime = match self.host.stat(tmpfile.as_path()) {
|
let prev_mtime: SystemTime = match self.host.stat(tmpfile.as_path()) {
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ impl FileTransferActivity {
|
|||||||
match self.host.exec(input.as_str()) {
|
match self.host.exec(input.as_str()) {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
// Reload files
|
// Reload files
|
||||||
self.log(LogLevel::Info, format!("\"{}\": {}", input, output));
|
self.log(LogLevel::Info, format!("\"{input}\": {output}"));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report err
|
// Report err
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not execute command \"{}\": {}", input, err),
|
format!("Could not execute command \"{input}\": {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,14 +28,14 @@ impl FileTransferActivity {
|
|||||||
// Reload files
|
// Reload files
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Info,
|
LogLevel::Info,
|
||||||
format!("\"{}\" (exitcode: {}): {}", input, rc, output),
|
format!("\"{input}\" (exitcode: {rc}): {output}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report err
|
// Report err
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not execute command \"{}\": {}", input, err),
|
format!("Could not execute command \"{input}\": {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ impl FileTransferActivity {
|
|||||||
pub(crate) fn action_local_find(&mut self, input: String) -> Result<Vec<File>, String> {
|
pub(crate) fn action_local_find(&mut self, input: String) -> Result<Vec<File>, String> {
|
||||||
match self.host.find(input.as_str()) {
|
match self.host.find(input.as_str()) {
|
||||||
Ok(entries) => Ok(entries),
|
Ok(entries) => Ok(entries),
|
||||||
Err(err) => Err(format!("Could not search for files: {}", err)),
|
Err(err) => Err(format!("Could not search for files: {err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn action_remote_find(&mut self, input: String) -> Result<Vec<File>, String> {
|
pub(crate) fn action_remote_find(&mut self, input: String) -> Result<Vec<File>, String> {
|
||||||
match self.client.as_mut().find(input.as_str()) {
|
match self.client.as_mut().find(input.as_str()) {
|
||||||
Ok(entries) => Ok(entries),
|
Ok(entries) => Ok(entries),
|
||||||
Err(err) => Err(format!("Could not search for files: {}", err)),
|
Err(err) => Err(format!("Could not search for files: {err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ impl FileTransferActivity {
|
|||||||
) {
|
) {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not upload file: {}", err),
|
format!("Could not upload file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ impl FileTransferActivity {
|
|||||||
) {
|
) {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not download file: {}", err),
|
format!("Could not download file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ impl FileTransferActivity {
|
|||||||
{
|
{
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not upload file: {}", err),
|
format!("Could not upload file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ impl FileTransferActivity {
|
|||||||
) {
|
) {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not download file: {}", err),
|
format!("Could not download file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ impl FileTransferActivity {
|
|||||||
match self.host.mkdir(PathBuf::from(input.as_str()).as_path()) {
|
match self.host.mkdir(PathBuf::from(input.as_str()).as_path()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Reload files
|
// Reload files
|
||||||
self.log(LogLevel::Info, format!("Created directory \"{}\"", input));
|
self.log(LogLevel::Info, format!("Created directory \"{input}\""));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report err
|
// Report err
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not create directory \"{}\": {}", input, err),
|
format!("Could not create directory \"{input}\": {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,13 +30,13 @@ impl FileTransferActivity {
|
|||||||
) {
|
) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Reload files
|
// Reload files
|
||||||
self.log(LogLevel::Info, format!("Created directory \"{}\"", input));
|
self.log(LogLevel::Info, format!("Created directory \"{input}\""));
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report err
|
// Report err
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not create directory \"{}\": {}", input, err),
|
format!("Could not create directory \"{input}\": {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ impl FileTransferActivity {
|
|||||||
if file_exists {
|
if file_exists {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Warn,
|
LogLevel::Warn,
|
||||||
format!("File \"{}\" already exists", input,),
|
format!("File \"{input}\" already exists",),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ impl FileTransferActivity {
|
|||||||
if file_exists {
|
if file_exists {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Warn,
|
LogLevel::Warn,
|
||||||
format!("File \"{}\" already exists", input,),
|
format!("File \"{input}\" already exists",),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ impl FileTransferActivity {
|
|||||||
match tempfile::NamedTempFile::new() {
|
match tempfile::NamedTempFile::new() {
|
||||||
Err(err) => self.log_and_alert(
|
Err(err) => self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not create tempfile: {}", err),
|
format!("Could not create tempfile: {err}"),
|
||||||
),
|
),
|
||||||
Ok(tfile) => {
|
Ok(tfile) => {
|
||||||
// Stat tempfile
|
// Stat tempfile
|
||||||
@@ -67,7 +67,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not stat tempfile: {}", err),
|
format!("Could not stat tempfile: {err}"),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not open tempfile: {}", err),
|
format!("Could not open tempfile: {err}"),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Failed to download remote entry: {}", err),
|
format!("Failed to download remote entry: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ impl FileTransferActivity {
|
|||||||
{
|
{
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not upload file: {}", err),
|
format!("Could not upload file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ impl FileTransferActivity {
|
|||||||
{
|
{
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not upload file: {}", err),
|
format!("Could not upload file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ impl FileTransferActivity {
|
|||||||
{
|
{
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not download file: {}", err),
|
format!("Could not download file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ impl FileTransferActivity {
|
|||||||
{
|
{
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not download file: {}", err),
|
format!("Could not download file: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not create symlink: {}", err),
|
format!("Could not create symlink: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ impl FileTransferActivity {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some(Err(err)) => {
|
Some(Err(err)) => {
|
||||||
self.log_and_alert(LogLevel::Error, format!("could not unwatch path: {}", err));
|
self.log_and_alert(LogLevel::Error, format!("could not unwatch path: {err}"));
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ impl FileInfoPopup {
|
|||||||
texts
|
texts
|
||||||
.add_row()
|
.add_row()
|
||||||
.add_col(TextSpan::from("Size: "))
|
.add_col(TextSpan::from("Size: "))
|
||||||
.add_col(TextSpan::new(format!("{} ({})", bsize, size).as_str()).fg(Color::Cyan));
|
.add_col(TextSpan::new(format!("{bsize} ({size})").as_str()).fg(Color::Cyan));
|
||||||
let atime: String = fmt_time(
|
let atime: String = fmt_time(
|
||||||
file.metadata().accessed.unwrap_or(UNIX_EPOCH),
|
file.metadata().accessed.unwrap_or(UNIX_EPOCH),
|
||||||
"%b %d %Y %H:%M:%S",
|
"%b %d %Y %H:%M:%S",
|
||||||
@@ -1330,7 +1330,7 @@ pub struct ReplacePopup {
|
|||||||
impl ReplacePopup {
|
impl ReplacePopup {
|
||||||
pub fn new(filename: Option<&str>, color: Color) -> Self {
|
pub fn new(filename: Option<&str>, color: Color) -> Self {
|
||||||
let text = match filename {
|
let text = match filename {
|
||||||
Some(f) => format!(r#"File "{}" already exists. Overwrite file?"#, f),
|
Some(f) => format!(r#"File "{f}" already exists. Overwrite file?"#),
|
||||||
None => "Overwrite files?".to_string(),
|
None => "Overwrite files?".to_string(),
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
@@ -1795,8 +1795,7 @@ impl SyncBrowsingMkdirPopup {
|
|||||||
.choices(&["Yes", "No"])
|
.choices(&["Yes", "No"])
|
||||||
.title(
|
.title(
|
||||||
format!(
|
format!(
|
||||||
r#"Sync browsing: directory "{}" doesn't exist. Do you want to create it?"#,
|
r#"Sync browsing: directory "{dir_name}" doesn't exist. Do you want to create it?"#
|
||||||
dir_name
|
|
||||||
),
|
),
|
||||||
Alignment::Center,
|
Alignment::Center,
|
||||||
),
|
),
|
||||||
@@ -1974,8 +1973,8 @@ pub struct WatcherPopup {
|
|||||||
impl WatcherPopup {
|
impl WatcherPopup {
|
||||||
pub fn new(watched: bool, local: &str, remote: &str, color: Color) -> Self {
|
pub fn new(watched: bool, local: &str, remote: &str, color: Color) -> Self {
|
||||||
let text = match watched {
|
let text = match watched {
|
||||||
false => format!(r#"Synchronize changes from "{}" to "{}"?"#, local, remote),
|
false => format!(r#"Synchronize changes from "{local}" to "{remote}"?"#),
|
||||||
true => format!(r#"Stop synchronizing changes at "{}"?"#, local),
|
true => format!(r#"Stop synchronizing changes at "{local}"?"#),
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
component: Radio::default()
|
component: Radio::default()
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("error while polling file watcher: {}", err),
|
format!("error while polling file watcher: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ impl FileTransferActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.mount_error(format!("Application error: {}", err));
|
self.mount_error(format!("Application error: {err}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ impl FileTransferActivity {
|
|||||||
);
|
);
|
||||||
match file_type {
|
match file_type {
|
||||||
None => base,
|
None => base,
|
||||||
Some(file_type) => format!("{}.{}", base, file_type),
|
Some(file_type) => format!("{base}.{file_type}"),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not scan current directory: {}", err),
|
format!("Could not scan current directory: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ impl FileTransferActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not scan current directory: {}", err),
|
format!("Could not scan current directory: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,7 +435,7 @@ impl FileTransferActivity {
|
|||||||
// Init transfer
|
// Init transfer
|
||||||
self.transfer.partial.init(file_size);
|
self.transfer.partial.init(file_size);
|
||||||
// rewind
|
// rewind
|
||||||
if let Err(err) = reader.seek(std::io::SeekFrom::Start(0)) {
|
if let Err(err) = reader.rewind() {
|
||||||
return Err(TransferErrorReason::CouldNotRewind(err));
|
return Err(TransferErrorReason::CouldNotRewind(err));
|
||||||
}
|
}
|
||||||
// Write remote file
|
// Write remote file
|
||||||
@@ -491,7 +491,7 @@ impl FileTransferActivity {
|
|||||||
// Draw only if a significant progress has been made (performance improvement)
|
// Draw only if a significant progress has been made (performance improvement)
|
||||||
if last_progress_val < self.transfer.partial.calc_progress() - 0.01 {
|
if last_progress_val < self.transfer.partial.calc_progress() - 0.01 {
|
||||||
// Draw
|
// Draw
|
||||||
self.update_progress_bar(format!("Uploading \"{}\"…", file_name));
|
self.update_progress_bar(format!("Uploading \"{file_name}\"…"));
|
||||||
self.view();
|
self.view();
|
||||||
last_progress_val = self.transfer.partial.calc_progress();
|
last_progress_val = self.transfer.partial.calc_progress();
|
||||||
}
|
}
|
||||||
@@ -500,7 +500,7 @@ impl FileTransferActivity {
|
|||||||
if let Err(err) = self.client.on_written(writer) {
|
if let Err(err) = self.client.on_written(writer) {
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Warn,
|
LogLevel::Warn,
|
||||||
format!("Could not finalize remote stream: \"{}\"", err),
|
format!("Could not finalize remote stream: \"{err}\""),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// if upload was abrupted, return error
|
// if upload was abrupted, return error
|
||||||
@@ -539,11 +539,11 @@ impl FileTransferActivity {
|
|||||||
// Init transfer
|
// Init transfer
|
||||||
self.transfer.partial.init(file_size);
|
self.transfer.partial.init(file_size);
|
||||||
// rewind
|
// rewind
|
||||||
if let Err(err) = reader.seek(std::io::SeekFrom::Start(0)) {
|
if let Err(err) = reader.rewind() {
|
||||||
return Err(TransferErrorReason::CouldNotRewind(err));
|
return Err(TransferErrorReason::CouldNotRewind(err));
|
||||||
}
|
}
|
||||||
// Draw before
|
// Draw before
|
||||||
self.update_progress_bar(format!("Uploading \"{}\"…", file_name));
|
self.update_progress_bar(format!("Uploading \"{file_name}\"…"));
|
||||||
self.view();
|
self.view();
|
||||||
// Send file
|
// Send file
|
||||||
if let Err(err) = self.client.create_file(remote, &metadata, Box::new(reader)) {
|
if let Err(err) = self.client.create_file(remote, &metadata, Box::new(reader)) {
|
||||||
@@ -553,7 +553,7 @@ impl FileTransferActivity {
|
|||||||
self.transfer.partial.update_progress(file_size);
|
self.transfer.partial.update_progress(file_size);
|
||||||
self.transfer.full.update_progress(file_size);
|
self.transfer.full.update_progress(file_size);
|
||||||
// Draw again after
|
// Draw again after
|
||||||
self.update_progress_bar(format!("Uploading \"{}\"…", file_name));
|
self.update_progress_bar(format!("Uploading \"{file_name}\"…"));
|
||||||
self.view();
|
self.view();
|
||||||
// log and return Ok
|
// log and return Ok
|
||||||
self.log(
|
self.log(
|
||||||
@@ -892,7 +892,7 @@ impl FileTransferActivity {
|
|||||||
// Draw only if a significant progress has been made (performance improvement)
|
// Draw only if a significant progress has been made (performance improvement)
|
||||||
if last_progress_val < self.transfer.partial.calc_progress() - 0.01 {
|
if last_progress_val < self.transfer.partial.calc_progress() - 0.01 {
|
||||||
// Draw
|
// Draw
|
||||||
self.update_progress_bar(format!("Downloading \"{}\"", file_name));
|
self.update_progress_bar(format!("Downloading \"{file_name}\""));
|
||||||
self.view();
|
self.view();
|
||||||
last_progress_val = self.transfer.partial.calc_progress();
|
last_progress_val = self.transfer.partial.calc_progress();
|
||||||
}
|
}
|
||||||
@@ -901,7 +901,7 @@ impl FileTransferActivity {
|
|||||||
if let Err(err) = self.client.on_read(reader) {
|
if let Err(err) = self.client.on_read(reader) {
|
||||||
self.log(
|
self.log(
|
||||||
LogLevel::Warn,
|
LogLevel::Warn,
|
||||||
format!("Could not finalize remote stream: \"{}\"", err),
|
format!("Could not finalize remote stream: \"{err}\""),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// If download was abrupted, return Error
|
// If download was abrupted, return Error
|
||||||
@@ -953,7 +953,7 @@ impl FileTransferActivity {
|
|||||||
// Init transfer
|
// Init transfer
|
||||||
self.transfer.partial.init(remote.metadata.size as usize);
|
self.transfer.partial.init(remote.metadata.size as usize);
|
||||||
// Draw before transfer
|
// Draw before transfer
|
||||||
self.update_progress_bar(format!("Downloading \"{}\"", file_name));
|
self.update_progress_bar(format!("Downloading \"{file_name}\""));
|
||||||
self.view();
|
self.view();
|
||||||
// recv wno stream
|
// recv wno stream
|
||||||
if let Err(err) = self.client.open_file(remote.path.as_path(), reader) {
|
if let Err(err) = self.client.open_file(remote.path.as_path(), reader) {
|
||||||
@@ -967,7 +967,7 @@ impl FileTransferActivity {
|
|||||||
.full
|
.full
|
||||||
.update_progress(remote.metadata.size as usize);
|
.update_progress(remote.metadata.size as usize);
|
||||||
// Draw after transfer
|
// Draw after transfer
|
||||||
self.update_progress_bar(format!("Downloading \"{}\"", file_name));
|
self.update_progress_bar(format!("Downloading \"{file_name}\""));
|
||||||
self.view();
|
self.view();
|
||||||
// Apply file mode to file
|
// Apply file mode to file
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
@@ -1018,7 +1018,7 @@ impl FileTransferActivity {
|
|||||||
// Report err
|
// Report err
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not change working directory: {}", err),
|
format!("Could not change working directory: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1045,7 @@ impl FileTransferActivity {
|
|||||||
// Report err
|
// Report err
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not change working directory: {}", err),
|
format!("Could not change working directory: {err}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ impl FileTransferActivity {
|
|||||||
TransferMsg::ExecuteCmd(cmd) => {
|
TransferMsg::ExecuteCmd(cmd) => {
|
||||||
// Exex command
|
// Exex command
|
||||||
self.umount_exec();
|
self.umount_exec();
|
||||||
self.mount_blocking_wait(format!("Executing '{}'…", cmd).as_str());
|
self.mount_blocking_wait(format!("Executing '{cmd}'…").as_str());
|
||||||
match self.browser.tab() {
|
match self.browser.tab() {
|
||||||
FileExplorerTab::Local => self.action_local_exec(cmd),
|
FileExplorerTab::Local => self.action_local_exec(cmd),
|
||||||
FileExplorerTab::Remote => self.action_remote_exec(cmd),
|
FileExplorerTab::Remote => self.action_remote_exec(cmd),
|
||||||
@@ -271,7 +271,7 @@ impl FileTransferActivity {
|
|||||||
TransferMsg::SearchFile(search) => {
|
TransferMsg::SearchFile(search) => {
|
||||||
self.umount_find_input();
|
self.umount_find_input();
|
||||||
// Mount wait
|
// Mount wait
|
||||||
self.mount_blocking_wait(format!(r#"Searching for "{}"…"#, search).as_str());
|
self.mount_blocking_wait(format!(r#"Searching for "{search}"…"#).as_str());
|
||||||
// Find
|
// Find
|
||||||
let res: Result<Vec<File>, String> = match self.browser.tab() {
|
let res: Result<Vec<File>, String> = match self.browser.tab() {
|
||||||
FileExplorerTab::Local => self.action_local_find(search.clone()),
|
FileExplorerTab::Local => self.action_local_find(search.clone()),
|
||||||
@@ -289,7 +289,7 @@ impl FileTransferActivity {
|
|||||||
Ok(files) if files.is_empty() => {
|
Ok(files) if files.is_empty() => {
|
||||||
// If no file has been found notify user
|
// If no file has been found notify user
|
||||||
self.mount_info(
|
self.mount_info(
|
||||||
format!(r#"Could not find any file matching "{}""#, search).as_str(),
|
format!(r#"Could not find any file matching "{search}""#).as_str(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ impl FileTransferActivity {
|
|||||||
.remount(
|
.remount(
|
||||||
Id::ExplorerFind,
|
Id::ExplorerFind,
|
||||||
Box::new(components::ExplorerFind::new(
|
Box::new(components::ExplorerFind::new(
|
||||||
format!(r#"Search results for "{}""#, search),
|
format!(r#"Search results for "{search}""#),
|
||||||
&[],
|
&[],
|
||||||
bg,
|
bg,
|
||||||
fg,
|
fg,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ impl SetupActivity {
|
|||||||
// Collect input values if in theme form
|
// Collect input values if in theme form
|
||||||
if self.layout == ViewLayout::Theme {
|
if self.layout == ViewLayout::Theme {
|
||||||
self.collect_styles()
|
self.collect_styles()
|
||||||
.map_err(|e| format!("'{:?}' has an invalid color", e))?;
|
.map_err(|e| format!("'{e:?}' has an invalid color"))?;
|
||||||
}
|
}
|
||||||
// save theme
|
// save theme
|
||||||
self.save_theme()
|
self.save_theme()
|
||||||
@@ -59,7 +59,7 @@ impl SetupActivity {
|
|||||||
ViewLayout::SetupForm => self.collect_input_values(),
|
ViewLayout::SetupForm => self.collect_input_values(),
|
||||||
ViewLayout::Theme => self
|
ViewLayout::Theme => self
|
||||||
.collect_styles()
|
.collect_styles()
|
||||||
.map_err(|e| format!("'{:?}' has an invalid color", e))?,
|
.map_err(|e| format!("'{e:?}' has an invalid color"))?,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
// Update view
|
// Update view
|
||||||
@@ -113,7 +113,7 @@ impl SetupActivity {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Report error
|
// Report error
|
||||||
self.mount_error(
|
self.mount_error(
|
||||||
format!("Could not get ssh key \"{}\": {}", key, err).as_str(),
|
format!("Could not get ssh key \"{key}\": {err}").as_str(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ impl SetupActivity {
|
|||||||
};
|
};
|
||||||
// Prepare text editor
|
// Prepare text editor
|
||||||
env::set_var("EDITOR", self.config().get_text_editor());
|
env::set_var("EDITOR", self.config().get_text_editor());
|
||||||
let placeholder: String = format!("# Type private SSH key for {}@{}\n", username, host);
|
let placeholder: String = format!("# Type private SSH key for {username}@{host}\n");
|
||||||
// Put input mode back to normal
|
// Put input mode back to normal
|
||||||
if let Err(err) = self.context_mut().terminal().disable_raw_mode() {
|
if let Err(err) = self.context_mut().terminal().disable_raw_mode() {
|
||||||
error!("Could not disable raw mode: {}", err);
|
error!("Could not disable raw mode: {}", err);
|
||||||
@@ -159,14 +159,14 @@ impl SetupActivity {
|
|||||||
self.add_ssh_key(host.as_str(), username.as_str(), rsa_key.as_str())
|
self.add_ssh_key(host.as_str(), username.as_str(), rsa_key.as_str())
|
||||||
{
|
{
|
||||||
self.mount_error(
|
self.mount_error(
|
||||||
format!("Could not create new private key: {}", err).as_str(),
|
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());
|
self.mount_error(format!("Could not write private key to file: {err}").as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Restore terminal
|
// Restore terminal
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ impl SetupActivity {
|
|||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Could not save configuration: {}", err);
|
error!("Could not save configuration: {}", err);
|
||||||
Err(format!("Could not save configuration: {}", err))
|
Err(format!("Could not save configuration: {err}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,21 +25,21 @@ impl SetupActivity {
|
|||||||
pub(super) fn reset_config_changes(&mut self) -> Result<(), String> {
|
pub(super) fn reset_config_changes(&mut self) -> Result<(), String> {
|
||||||
self.config_mut()
|
self.config_mut()
|
||||||
.read_config()
|
.read_config()
|
||||||
.map_err(|e| format!("Could not reload configuration: {}", e))
|
.map_err(|e| format!("Could not reload configuration: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save theme to file
|
/// Save theme to file
|
||||||
pub(super) fn save_theme(&mut self) -> Result<(), String> {
|
pub(super) fn save_theme(&mut self) -> Result<(), String> {
|
||||||
self.theme_provider()
|
self.theme_provider()
|
||||||
.save()
|
.save()
|
||||||
.map_err(|e| format!("Could not save theme: {}", e))
|
.map_err(|e| format!("Could not save theme: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reset changes committed to theme
|
/// Reset changes committed to theme
|
||||||
pub(super) fn reset_theme_changes(&mut self) -> Result<(), String> {
|
pub(super) fn reset_theme_changes(&mut self) -> Result<(), String> {
|
||||||
self.theme_provider()
|
self.theme_provider()
|
||||||
.load()
|
.load()
|
||||||
.map_err(|e| format!("Could not restore theme: {}", e))
|
.map_err(|e| format!("Could not restore theme: {e}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delete ssh key from config cli
|
/// Delete ssh key from config cli
|
||||||
@@ -47,8 +47,7 @@ impl SetupActivity {
|
|||||||
match self.config_mut().del_ssh_key(host, username) {
|
match self.config_mut().del_ssh_key(host, username) {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(err) => Err(format!(
|
Err(err) => Err(format!(
|
||||||
"Could not delete ssh key \"{}@{}\": {}",
|
"Could not delete ssh key \"{host}@{username}\": {err}"
|
||||||
host, username, err
|
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,11 +79,11 @@ impl SetupActivity {
|
|||||||
Some((_, _, key_path)) => {
|
Some((_, _, key_path)) => {
|
||||||
match edit::edit_file(key_path.as_path()) {
|
match edit::edit_file(key_path.as_path()) {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(err) => Err(format!("Could not edit ssh key: {}", err)),
|
Err(err) => Err(format!("Could not edit ssh key: {err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(err) => Err(format!("Could not read ssh key: {}", err)),
|
Err(err) => Err(format!("Could not read ssh key: {err}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
@@ -119,6 +118,6 @@ impl SetupActivity {
|
|||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
self.config_mut()
|
self.config_mut()
|
||||||
.add_ssh_key(host, username, rsa_key)
|
.add_ssh_key(host, username, rsa_key)
|
||||||
.map_err(|e| format!("Could not add SSH key: {}", e))
|
.map_err(|e| format!("Could not add SSH key: {e}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ impl Activity for SetupActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.mount_error(format!("Application error: {}", err));
|
self.mount_error(format!("Application error: {err}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// View
|
// View
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ impl SetupActivity {
|
|||||||
.iter_ssh_keys()
|
.iter_ssh_keys()
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
let (addr, username, _) = self.config().get_ssh_key(x).ok().unwrap().unwrap();
|
let (addr, username, _) = self.config().get_ssh_key(x).ok().unwrap().unwrap();
|
||||||
format!("{} at {}", username, addr)
|
format!("{username} at {addr}")
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
assert!(self
|
assert!(self
|
||||||
|
|||||||
+2
-2
@@ -254,7 +254,7 @@ pub fn fmt_color(color: &Color) -> String {
|
|||||||
Color::Rgb(255, 255, 0) => "yellow".to_string(),
|
Color::Rgb(255, 255, 0) => "yellow".to_string(),
|
||||||
Color::Rgb(154, 205, 50) => "yellowgreen".to_string(),
|
Color::Rgb(154, 205, 50) => "yellowgreen".to_string(),
|
||||||
// -- others
|
// -- others
|
||||||
Color::Rgb(r, g, b) => format!("#{:02x}{:02x}{:02x}", r, g, b),
|
Color::Rgb(r, g, b) => format!("#{r:02x}{g:02x}{b:02x}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ pub fn fmt_bytes(v: u64) -> String {
|
|||||||
} else if v >= 1024 {
|
} else if v >= 1024 {
|
||||||
format!("{} KB", v / 1024)
|
format!("{} KB", v / 1024)
|
||||||
} else {
|
} else {
|
||||||
format!("{} B", v)
|
format!("{v} B")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub fn create_sample_file() -> NamedTempFile {
|
|||||||
/// Create sample file with provided content
|
/// Create sample file with provided content
|
||||||
pub fn create_sample_file_with_content(content: impl std::fmt::Display) -> NamedTempFile {
|
pub fn create_sample_file_with_content(content: impl std::fmt::Display) -> NamedTempFile {
|
||||||
let mut tmpfile: tempfile::NamedTempFile = tempfile::NamedTempFile::new().unwrap();
|
let mut tmpfile: tempfile::NamedTempFile = tempfile::NamedTempFile::new().unwrap();
|
||||||
writeln!(tmpfile, "{}", content).unwrap();
|
writeln!(tmpfile, "{content}").unwrap();
|
||||||
tmpfile
|
tmpfile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user