This commit is contained in:
veeso
2022-08-17 10:33:31 +02:00
parent cce0c92c0b
commit a22c5025d7
21 changed files with 52 additions and 52 deletions

View File

@@ -1,5 +1,5 @@
[package]
authors = ["Christian Visintin"]
authors = ["Christian Visintin <christian.visintin1997@gmail.com>"]
categories = ["command-line-utilities"]
description = "termscp is a feature rich terminal file transfer and explorer with support for SCP/SFTP/FTP/S3"
edition = "2021"

View File

@@ -19,7 +19,7 @@ pub struct UserHosts {
}
/// Bookmark describes a single bookmark entry in the user hosts storage
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq)]
pub struct Bookmark {
#[serde(
deserialize_with = "deserialize_protocol",
@@ -41,7 +41,7 @@ pub struct Bookmark {
}
/// Connection parameters for Aws s3 protocol
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Default)]
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq, Default)]
pub struct S3Params {
pub bucket: String,
pub region: Option<String>,

View File

@@ -106,7 +106,7 @@ mod tests {
assert_eq!(ui.file_fmt, Some(String::from("{NAME}")));
let cfg: UserConfig = UserConfig {
user_interface: ui,
remote: remote,
remote,
};
assert_eq!(
*cfg.remote

View File

@@ -12,7 +12,7 @@ use tuirealm::tui::style::Color;
/// ### Theme
///
/// Theme contains all the colors lookup table for termscp
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
pub struct Theme {
// -- auth
#[serde(

View File

@@ -25,7 +25,7 @@ bitflags! {
}
/// FileSorting defines the criteria for sorting files
#[derive(Copy, Clone, PartialEq, std::fmt::Debug)]
#[derive(Copy, Clone, PartialEq, Eq, std::fmt::Debug)]
pub enum FileSorting {
Name,
ModifyTime,
@@ -34,7 +34,7 @@ pub enum FileSorting {
}
/// GroupDirs defines how directories should be grouped in sorting files
#[derive(PartialEq, std::fmt::Debug)]
#[derive(PartialEq, Eq, std::fmt::Debug)]
pub enum GroupDirs {
First,
Last,
@@ -318,8 +318,8 @@ mod tests {
explorer.stack_size = 2;
explorer.dirstack = VecDeque::with_capacity(2);
// Push dir
explorer.pushd(&Path::new("/tmp"));
explorer.pushd(&Path::new("/home/omar"));
explorer.pushd(Path::new("/tmp"));
explorer.pushd(Path::new("/home/omar"));
// Pop
assert_eq!(explorer.popd().unwrap(), PathBuf::from("/home/omar"));
assert_eq!(explorer.dirstack.len(), 1);
@@ -328,9 +328,9 @@ mod tests {
// Dirstack is empty now
assert!(explorer.popd().is_none());
// Exceed limit
explorer.pushd(&Path::new("/tmp"));
explorer.pushd(&Path::new("/home/omar"));
explorer.pushd(&Path::new("/dev"));
explorer.pushd(Path::new("/tmp"));
explorer.pushd(Path::new("/home/omar"));
explorer.pushd(Path::new("/dev"));
assert_eq!(explorer.dirstack.len(), 2);
assert_eq!(*explorer.dirstack.get(1).unwrap(), PathBuf::from("/dev"));
assert_eq!(

View File

@@ -11,7 +11,7 @@ pub use params::{FileTransferParams, ProtocolParams};
/// This enum defines the different transfer protocol available in termscp
#[derive(PartialEq, Debug, Clone, Copy)]
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub enum FileTransferProtocol {
Sftp,
Scp,

View File

@@ -654,7 +654,7 @@ mod tests {
let entries = std::fs::read_dir(PathBuf::from("/dev").as_path()).unwrap();
let mut counter: usize = 0;
for _ in entries {
counter = counter + 1;
counter += 1;
}
assert_eq!(host.files.len(), counter);
}
@@ -696,7 +696,7 @@ mod tests {
let entries = std::fs::read_dir(PathBuf::from("/dev").as_path()).unwrap();
let mut counter: usize = 0;
for _ in entries {
counter = counter + 1;
counter += 1;
}
assert_eq!(host.list_dir().len(), counter);
}
@@ -709,10 +709,10 @@ mod tests {
assert!(host.change_wrkdir(new_dir.as_path()).is_ok());
// Verify new files
// Scan dir
let entries = std::fs::read_dir(PathBuf::from(new_dir).as_path()).unwrap();
let entries = std::fs::read_dir(new_dir.as_path()).unwrap();
let mut counter: usize = 0;
for _ in entries {
counter = counter + 1;
counter += 1;
}
assert_eq!(host.files.len(), counter);
}
@@ -793,7 +793,7 @@ mod tests {
let files: Vec<File> = host.list_dir();
// Verify files
let file_0: &File = files.get(0).unwrap();
if file_0.name() == String::from("foo.txt") {
if file_0.name() == *"foo.txt" {
assert!(file_0.metadata.symlink.is_none());
} else {
assert_eq!(
@@ -803,7 +803,7 @@ mod tests {
}
// Verify simlink
let file_1: &File = files.get(1).unwrap();
if file_1.name() == String::from("bar.txt") {
if file_1.name() == *"bar.txt" {
assert_eq!(
file_1.metadata.symlink.as_ref().unwrap(),
&PathBuf::from(format!("{}/foo.txt", tmpdir.path().display()))

View File

@@ -491,7 +491,7 @@ mod tests {
// Verify client has updated parameters
assert_eq!(client.get_default_protocol(), FileTransferProtocol::Scp);
assert_eq!(client.get_text_editor(), PathBuf::from("/usr/bin/vim"));
let mut expected_key_path: PathBuf = key_path.clone();
let mut expected_key_path: PathBuf = key_path;
expected_key_path.push("pi@192.168.1.31.key");
assert_eq!(
client.get_ssh_key("pi@192.168.1.31").unwrap().unwrap(),

View File

@@ -126,7 +126,7 @@ mod tests {
#[serial]
fn test_system_environment_get_bookmarks_paths() {
assert_eq!(
get_bookmarks_paths(&Path::new("/home/omar/.config/termscp/")),
get_bookmarks_paths(Path::new("/home/omar/.config/termscp/")),
PathBuf::from("/home/omar/.config/termscp/bookmarks.toml"),
);
}
@@ -135,7 +135,7 @@ mod tests {
#[serial]
fn test_system_environment_get_config_paths() {
assert_eq!(
get_config_paths(&Path::new("/home/omar/.config/termscp/")),
get_config_paths(Path::new("/home/omar/.config/termscp/")),
(
PathBuf::from("/home/omar/.config/termscp/config.toml"),
PathBuf::from("/home/omar/.config/termscp/.ssh/")
@@ -147,7 +147,7 @@ mod tests {
#[serial]
fn test_system_environment_get_log_paths() {
assert_eq!(
get_log_paths(&Path::new("/home/omar/.config/termscp/")),
get_log_paths(Path::new("/home/omar/.config/termscp/")),
PathBuf::from("/home/omar/.config/termscp/termscp.log"),
);
}
@@ -156,7 +156,7 @@ mod tests {
#[serial]
fn test_system_environment_get_theme_path() {
assert_eq!(
get_theme_path(&Path::new("/home/omar/.config/termscp/")),
get_theme_path(Path::new("/home/omar/.config/termscp/")),
PathBuf::from("/home/omar/.config/termscp/theme.toml"),
);
}

View File

@@ -96,7 +96,7 @@ mod tests {
#[test]
fn test_system_keys_filestorage_make_dir() {
let storage: FileStorage = FileStorage::new(&Path::new("/tmp/"));
let storage: FileStorage = FileStorage::new(Path::new("/tmp/"));
assert_eq!(
storage.make_file_path("bookmarks").as_path(),
Path::new("/tmp/.bookmarks.key")

View File

@@ -10,7 +10,7 @@ pub mod keyringstorage;
use thiserror::Error;
/// defines the error type for the `KeyStorage`
#[derive(Debug, Error, PartialEq)]
#[derive(Debug, Error, PartialEq, Eq)]
pub enum KeyStorageError {
#[cfg(feature = "with-keyring")]
#[error("Key has a bad syntax")]

View File

@@ -93,7 +93,7 @@ mod tests {
// Create ssh key storage
let storage: SshKeyStorage = SshKeyStorage::from(&client);
// Verify key exists
let mut exp_key_path: PathBuf = key_path.clone();
let mut exp_key_path: PathBuf = key_path;
exp_key_path.push("pi@192.168.1.31.key");
assert_eq!(
*storage.resolve("192.168.1.31", "pi").unwrap(),

View File

@@ -60,14 +60,14 @@ pub enum Id {
WindowSizeError,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub enum Msg {
Form(FormMsg),
Ui(UiMsg),
None,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum FormMsg {
Connect,
DeleteBookmark,
@@ -81,7 +81,7 @@ pub enum FormMsg {
SaveBookmark,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum UiMsg {
AddressBlurDown,
AddressBlurUp,

View File

@@ -208,7 +208,7 @@ impl FileTransferActivity {
Ok(h) => {
let hostname: String = h.as_os_str().to_string_lossy().to_string();
let tokens: Vec<&str> = hostname.split('.').collect();
String::from(*tokens.get(0).unwrap_or(&"localhost"))
String::from(*tokens.first().unwrap_or(&"localhost"))
}
Err(_) => String::from("localhost"),
};

View File

@@ -102,7 +102,7 @@ impl FileTransferActivity {
self.action_submit_local(entry);
// Update file list if sync
if self.browser.sync_browsing && self.browser.found().is_none() {
let _ = self.update_remote_filelist();
self.update_remote_filelist();
}
self.update_local_filelist();
}
@@ -112,7 +112,7 @@ impl FileTransferActivity {
self.action_submit_remote(entry);
// Update file list if sync
if self.browser.sync_browsing && self.browser.found().is_none() {
let _ = self.update_local_filelist();
self.update_local_filelist();
}
self.update_remote_filelist();
}
@@ -161,7 +161,7 @@ impl FileTransferActivity {
FileExplorerTab::Local => {
self.action_go_to_local_upper_dir();
if self.browser.sync_browsing && self.browser.found().is_none() {
let _ = self.update_remote_filelist();
self.update_remote_filelist();
}
// Reload file list component
self.update_local_filelist()
@@ -169,7 +169,7 @@ impl FileTransferActivity {
FileExplorerTab::Remote => {
self.action_go_to_remote_upper_dir();
if self.browser.sync_browsing && self.browser.found().is_none() {
let _ = self.update_local_filelist();
self.update_local_filelist();
}
// Reload file list component
self.update_remote_filelist()
@@ -182,7 +182,7 @@ impl FileTransferActivity {
FileExplorerTab::Local => {
self.action_go_to_previous_local_dir();
if self.browser.sync_browsing && self.browser.found().is_none() {
let _ = self.update_remote_filelist();
self.update_remote_filelist();
}
// Reload file list component
self.update_local_filelist()
@@ -190,7 +190,7 @@ impl FileTransferActivity {
FileExplorerTab::Remote => {
self.action_go_to_previous_remote_dir();
if self.browser.sync_browsing && self.browser.found().is_none() {
let _ = self.update_local_filelist();
self.update_local_filelist();
}
// Reload file list component
self.update_remote_filelist()

View File

@@ -80,8 +80,8 @@ impl FileTransferActivity {
self.refresh_local_status_bar();
self.refresh_remote_status_bar();
// Update components
let _ = self.update_local_filelist();
let _ = self.update_remote_filelist();
self.update_local_filelist();
self.update_remote_filelist();
// Global listener
self.mount_global_listener();
// Give focus to local explorer

View File

@@ -278,7 +278,7 @@ impl NotificationsThreshold {
parse_bytesize(bytes).is_some()
}
fn char_valid(_input: &str, incoming: char) -> bool {
incoming.is_digit(10) || ['B', 'K', 'M', 'G', 'T', 'P'].contains(&incoming)
incoming.is_ascii_digit() || ['B', 'K', 'M', 'G', 'T', 'P'].contains(&incoming)
}
Self {
component: Input::default()

View File

@@ -99,7 +99,7 @@ pub enum IdTheme {
TransferTitle2,
}
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Msg {
Common(CommonMsg),
Config(ConfigMsg),
@@ -108,7 +108,7 @@ pub enum Msg {
None,
}
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CommonMsg {
ChangeLayout,
CloseErrorPopup,
@@ -125,7 +125,7 @@ pub enum CommonMsg {
WindowResized,
}
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ConfigMsg {
CheckUpdatesBlurDown,
CheckUpdatesBlurUp,
@@ -152,7 +152,7 @@ pub enum ConfigMsg {
TextEditorBlurUp,
}
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SshMsg {
CloseDelSshKeyPopup,
CloseNewSshKeyPopup,
@@ -165,7 +165,7 @@ pub enum SshMsg {
SshUsernameBlur,
}
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ThemeMsg {
AuthAddressBlurDown,
AuthAddressBlurUp,
@@ -230,7 +230,7 @@ const STORE_CONFIG_CHANGED: &str = "SETUP_CONFIG_CHANGED";
/// ### ViewLayout
///
/// Current view layout
#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
pub enum ViewLayout {
SetupForm,
SshKeys,

View File

@@ -32,7 +32,7 @@ mod tests {
fn test_utils_crypto_aes128() {
let key: &str = "MYSUPERSECRETKEY";
let input: &str = "Hello world!";
let secret: String = aes128_b64_crypt(&key, input);
let secret: String = aes128_b64_crypt(key, input);
assert_eq!(secret.as_str(), "z4Z6LpcpYqBW4+bkIok+5A==");
assert_eq!(
aes128_b64_decrypt(key, secret.as_str())

View File

@@ -300,7 +300,7 @@ mod tests {
#[test]
fn test_utils_fmt_time() {
let system_time: SystemTime = SystemTime::from(SystemTime::UNIX_EPOCH);
let system_time: SystemTime = SystemTime::UNIX_EPOCH;
assert_eq!(
fmt_time(system_time, "%Y-%m-%d"),
String::from("1970-01-01")
@@ -326,12 +326,12 @@ mod tests {
#[test]
#[cfg(target_family = "unix")]
fn test_utils_fmt_path_elide() {
let p: &Path = &Path::new("/develop/pippo");
let p: &Path = Path::new("/develop/pippo");
// Under max size
assert_eq!(fmt_path_elide(p, 16), String::from("/develop/pippo"));
// Above max size, only one ancestor
assert_eq!(fmt_path_elide(p, 8), String::from("/develop/pippo"));
let p: &Path = &Path::new("/develop/pippo/foo/bar");
let p: &Path = Path::new("/develop/pippo/foo/bar");
assert_eq!(fmt_path_elide(p, 16), String::from("/develop/…/foo/bar"));
}

View File

@@ -94,11 +94,11 @@ mod test {
#[test]
fn absolutize_path() {
assert_eq!(
absolutize(&Path::new("/home/omar"), &Path::new("readme.txt")).as_path(),
absolutize(Path::new("/home/omar"), Path::new("readme.txt")).as_path(),
Path::new("/home/omar/readme.txt")
);
assert_eq!(
absolutize(&Path::new("/home/omar"), &Path::new("/tmp/readme.txt")).as_path(),
absolutize(Path::new("/home/omar"), Path::new("/tmp/readme.txt")).as_path(),
Path::new("/tmp/readme.txt")
);
}