linter
This commit is contained in:
parent
6cfac57162
commit
764cca73d1
|
@ -1,6 +1,7 @@
|
|||
# Changelog
|
||||
|
||||
- [Changelog](#changelog)
|
||||
- [0.7.0](#070)
|
||||
- [0.6.0](#060)
|
||||
- [0.5.1](#051)
|
||||
- [0.5.0](#050)
|
||||
|
@ -19,6 +20,12 @@
|
|||
|
||||
---
|
||||
|
||||
## 0.7.0
|
||||
|
||||
Released on ??
|
||||
|
||||
> 🍁 Autumn update 🍇
|
||||
|
||||
## 0.6.0
|
||||
|
||||
Released on 23/07/2021
|
||||
|
|
|
@ -188,7 +188,7 @@ impl ActivityManager {
|
|||
};
|
||||
// If ft params is None, return None
|
||||
let ft_params: &FileTransferParams = match ctx.ft_params() {
|
||||
Some(ft_params) => &ft_params,
|
||||
Some(ft_params) => ft_params,
|
||||
None => {
|
||||
error!("Failed to start FileTransferActivity: file transfer params is None");
|
||||
return None;
|
||||
|
|
|
@ -44,13 +44,13 @@ pub struct SerializerError {
|
|||
#[derive(Error, Debug)]
|
||||
pub enum SerializerErrorKind {
|
||||
#[error("Operation failed")]
|
||||
GenericError,
|
||||
Generic,
|
||||
#[error("IO error")]
|
||||
IoError,
|
||||
Io,
|
||||
#[error("Serialization error")]
|
||||
SerializationError,
|
||||
Serialization,
|
||||
#[error("Syntax error")]
|
||||
SyntaxError,
|
||||
Syntax,
|
||||
}
|
||||
|
||||
impl SerializerError {
|
||||
|
@ -92,7 +92,7 @@ where
|
|||
Ok(dt) => dt,
|
||||
Err(err) => {
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::SerializationError,
|
||||
SerializerErrorKind::Serialization,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ where
|
|||
match writable.write_all(data.as_bytes()) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
)),
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ where
|
|||
let mut data: String = String::new();
|
||||
if let Err(err) = readable.read_to_string(&mut data) {
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
));
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ where
|
|||
Ok(deserialized)
|
||||
}
|
||||
Err(err) => Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::SyntaxError,
|
||||
SerializerErrorKind::Syntax,
|
||||
err.to_string(),
|
||||
)),
|
||||
}
|
||||
|
@ -154,11 +154,11 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_config_serialization_errors() {
|
||||
let error: SerializerError = SerializerError::new(SerializerErrorKind::SyntaxError);
|
||||
let error: SerializerError = SerializerError::new(SerializerErrorKind::Syntax);
|
||||
assert!(error.msg.is_none());
|
||||
assert_eq!(format!("{}", error), String::from("Syntax error"));
|
||||
let error: SerializerError =
|
||||
SerializerError::new_ex(SerializerErrorKind::SyntaxError, String::from("bad syntax"));
|
||||
SerializerError::new_ex(SerializerErrorKind::Syntax, String::from("bad syntax"));
|
||||
assert!(error.msg.is_some());
|
||||
assert_eq!(
|
||||
format!("{}", error),
|
||||
|
@ -166,20 +166,17 @@ mod tests {
|
|||
);
|
||||
// Fmt
|
||||
assert_eq!(
|
||||
format!(
|
||||
"{}",
|
||||
SerializerError::new(SerializerErrorKind::GenericError)
|
||||
),
|
||||
format!("{}", SerializerError::new(SerializerErrorKind::Generic)),
|
||||
String::from("Operation failed")
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", SerializerError::new(SerializerErrorKind::IoError)),
|
||||
format!("{}", SerializerError::new(SerializerErrorKind::Io)),
|
||||
String::from("IO error")
|
||||
);
|
||||
assert_eq!(
|
||||
format!(
|
||||
"{}",
|
||||
SerializerError::new(SerializerErrorKind::SerializationError)
|
||||
SerializerError::new(SerializerErrorKind::Serialization)
|
||||
),
|
||||
String::from("Serialization error")
|
||||
);
|
||||
|
|
|
@ -189,7 +189,7 @@ impl FtpFileTransfer {
|
|||
FsEntry::Directory(FsDirectory {
|
||||
name: p
|
||||
.file_name()
|
||||
.unwrap_or(&std::ffi::OsStr::new(""))
|
||||
.unwrap_or_else(|| std::ffi::OsStr::new(""))
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
abs_path: p.clone(),
|
||||
|
@ -206,7 +206,7 @@ impl FtpFileTransfer {
|
|||
false => FsEntry::File(FsFile {
|
||||
name: p
|
||||
.file_name()
|
||||
.unwrap_or(&std::ffi::OsStr::new(""))
|
||||
.unwrap_or_else(|| std::ffi::OsStr::new(""))
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
abs_path: p.clone(),
|
||||
|
@ -659,7 +659,7 @@ impl FileTransfer for FtpFileTransfer {
|
|||
// Remove recursively files
|
||||
debug!("Removing {} entries from directory...", files.len());
|
||||
for file in files.iter() {
|
||||
if let Err(err) = self.remove(&file) {
|
||||
if let Err(err) = self.remove(file) {
|
||||
return Err(FileTransferError::new_ex(
|
||||
FileTransferErrorType::PexError,
|
||||
err.to_string(),
|
||||
|
|
|
@ -169,7 +169,7 @@ impl ScpFileTransfer {
|
|||
// Get symlink; PATH mustn't be equal to filename
|
||||
let symlink: Option<Box<FsEntry>> = match symlink_path {
|
||||
None => None,
|
||||
Some(p) => match p.file_name().unwrap_or(&std::ffi::OsStr::new(""))
|
||||
Some(p) => match p.file_name().unwrap_or_else(|| std::ffi::OsStr::new(""))
|
||||
== file_name.as_str()
|
||||
{
|
||||
// If name is equal, don't stat path; otherwise it would get stuck
|
||||
|
@ -339,7 +339,7 @@ impl FileTransfer for ScpFileTransfer {
|
|||
// Try addresses
|
||||
for socket_addr in socket_addresses.iter() {
|
||||
debug!("Trying socket address {}", socket_addr);
|
||||
match TcpStream::connect_timeout(&socket_addr, Duration::from_secs(30)) {
|
||||
match TcpStream::connect_timeout(socket_addr, Duration::from_secs(30)) {
|
||||
Ok(stream) => {
|
||||
debug!("{} succeded", socket_addr);
|
||||
tcp = Some(stream);
|
||||
|
|
|
@ -282,7 +282,7 @@ impl FileTransfer for SftpFileTransfer {
|
|||
// Try addresses
|
||||
for socket_addr in socket_addresses.iter() {
|
||||
debug!("Trying socket address {}", socket_addr);
|
||||
match TcpStream::connect_timeout(&socket_addr, Duration::from_secs(30)) {
|
||||
match TcpStream::connect_timeout(socket_addr, Duration::from_secs(30)) {
|
||||
Ok(stream) => {
|
||||
tcp = Some(stream);
|
||||
break;
|
||||
|
@ -602,7 +602,7 @@ impl FileTransfer for SftpFileTransfer {
|
|||
// Get directory files
|
||||
let directory_content: Vec<FsEntry> = self.list_dir(d.abs_path.as_path())?;
|
||||
for entry in directory_content.iter() {
|
||||
if let Err(err) = self.remove(&entry) {
|
||||
if let Err(err) = self.remove(entry) {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ mod tests {
|
|||
let explorer: FileExplorer = FileExplorerBuilder::new().build();
|
||||
// Verify
|
||||
assert!(!explorer.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES));
|
||||
assert_eq!(explorer.file_sorting, FileSorting::ByName); // Default
|
||||
assert_eq!(explorer.file_sorting, FileSorting::Name); // Default
|
||||
assert_eq!(explorer.group_dirs, None);
|
||||
assert_eq!(explorer.stack_size, 16);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_fs_explorer_builder_new_all() {
|
||||
let explorer: FileExplorer = FileExplorerBuilder::new()
|
||||
.with_file_sorting(FileSorting::ByModifyTime)
|
||||
.with_file_sorting(FileSorting::ModifyTime)
|
||||
.with_group_dirs(Some(GroupDirs::First))
|
||||
.with_hidden_files(true)
|
||||
.with_stack_size(24)
|
||||
|
@ -140,7 +140,7 @@ mod tests {
|
|||
.build();
|
||||
// Verify
|
||||
assert!(explorer.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES));
|
||||
assert_eq!(explorer.file_sorting, FileSorting::ByModifyTime); // Default
|
||||
assert_eq!(explorer.file_sorting, FileSorting::ModifyTime); // Default
|
||||
assert_eq!(explorer.group_dirs, Some(GroupDirs::First));
|
||||
assert_eq!(explorer.stack_size, 24);
|
||||
}
|
||||
|
|
|
@ -52,10 +52,10 @@ bitflags! {
|
|||
/// FileSorting defines the criteria for sorting files
|
||||
#[derive(Copy, Clone, PartialEq, std::fmt::Debug)]
|
||||
pub enum FileSorting {
|
||||
ByName,
|
||||
ByModifyTime,
|
||||
ByCreationTime,
|
||||
BySize,
|
||||
Name,
|
||||
ModifyTime,
|
||||
CreationTime,
|
||||
Size,
|
||||
}
|
||||
|
||||
/// ## GroupDirs
|
||||
|
@ -87,7 +87,7 @@ impl Default for FileExplorer {
|
|||
wrkdir: PathBuf::from("/"),
|
||||
dirstack: VecDeque::with_capacity(16),
|
||||
stack_size: 16,
|
||||
file_sorting: FileSorting::ByName,
|
||||
file_sorting: FileSorting::Name,
|
||||
group_dirs: None,
|
||||
opts: ExplorerOpts::empty(),
|
||||
fmt: Formatter::default(),
|
||||
|
@ -237,10 +237,10 @@ impl FileExplorer {
|
|||
fn sort(&mut self) {
|
||||
// Choose sorting method
|
||||
match &self.file_sorting {
|
||||
FileSorting::ByName => self.sort_files_by_name(),
|
||||
FileSorting::ByCreationTime => self.sort_files_by_creation_time(),
|
||||
FileSorting::ByModifyTime => self.sort_files_by_mtime(),
|
||||
FileSorting::BySize => self.sort_files_by_size(),
|
||||
FileSorting::Name => self.sort_files_by_name(),
|
||||
FileSorting::CreationTime => self.sort_files_by_creation_time(),
|
||||
FileSorting::ModifyTime => self.sort_files_by_mtime(),
|
||||
FileSorting::Size => self.sort_files_by_size(),
|
||||
}
|
||||
// Directories first (NOTE: MUST COME AFTER OTHER SORTING)
|
||||
// Group directories if necessary
|
||||
|
@ -318,10 +318,10 @@ impl FileExplorer {
|
|||
impl ToString for FileSorting {
|
||||
fn to_string(&self) -> String {
|
||||
String::from(match self {
|
||||
FileSorting::ByCreationTime => "by_creation_time",
|
||||
FileSorting::ByModifyTime => "by_mtime",
|
||||
FileSorting::ByName => "by_name",
|
||||
FileSorting::BySize => "by_size",
|
||||
FileSorting::CreationTime => "by_creation_time",
|
||||
FileSorting::ModifyTime => "by_mtime",
|
||||
FileSorting::Name => "by_name",
|
||||
FileSorting::Size => "by_size",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -330,10 +330,10 @@ impl FromStr for FileSorting {
|
|||
type Err = ();
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.to_ascii_lowercase().as_str() {
|
||||
"by_creation_time" => Ok(FileSorting::ByCreationTime),
|
||||
"by_mtime" => Ok(FileSorting::ByModifyTime),
|
||||
"by_name" => Ok(FileSorting::ByName),
|
||||
"by_size" => Ok(FileSorting::BySize),
|
||||
"by_creation_time" => Ok(FileSorting::CreationTime),
|
||||
"by_mtime" => Ok(FileSorting::ModifyTime),
|
||||
"by_name" => Ok(FileSorting::Name),
|
||||
"by_size" => Ok(FileSorting::Size),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
@ -380,8 +380,8 @@ mod tests {
|
|||
assert_eq!(explorer.wrkdir, PathBuf::from("/"));
|
||||
assert_eq!(explorer.stack_size, 16);
|
||||
assert_eq!(explorer.group_dirs, None);
|
||||
assert_eq!(explorer.file_sorting, FileSorting::ByName);
|
||||
assert_eq!(explorer.get_file_sorting(), FileSorting::ByName);
|
||||
assert_eq!(explorer.file_sorting, FileSorting::Name);
|
||||
assert_eq!(explorer.get_file_sorting(), FileSorting::Name);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -459,7 +459,7 @@ mod tests {
|
|||
make_fs_entry("Cargo.lock", false),
|
||||
make_fs_entry("codecov.yml", false),
|
||||
]);
|
||||
explorer.sort_by(FileSorting::ByName);
|
||||
explorer.sort_by(FileSorting::Name);
|
||||
// First entry should be "Cargo.lock"
|
||||
assert_eq!(explorer.files.get(0).unwrap().get_name(), "Cargo.lock");
|
||||
// Last should be "src/"
|
||||
|
@ -475,7 +475,7 @@ mod tests {
|
|||
let entry2: FsEntry = make_fs_entry("CODE_OF_CONDUCT.md", false);
|
||||
// Create files (files are then sorted by name)
|
||||
explorer.set_files(vec![entry1, entry2]);
|
||||
explorer.sort_by(FileSorting::ByModifyTime);
|
||||
explorer.sort_by(FileSorting::ModifyTime);
|
||||
// First entry should be "CODE_OF_CONDUCT.md"
|
||||
assert_eq!(
|
||||
explorer.files.get(0).unwrap().get_name(),
|
||||
|
@ -494,7 +494,7 @@ mod tests {
|
|||
let entry2: FsEntry = make_fs_entry("CODE_OF_CONDUCT.md", false);
|
||||
// Create files (files are then sorted by name)
|
||||
explorer.set_files(vec![entry1, entry2]);
|
||||
explorer.sort_by(FileSorting::ByCreationTime);
|
||||
explorer.sort_by(FileSorting::CreationTime);
|
||||
// First entry should be "CODE_OF_CONDUCT.md"
|
||||
assert_eq!(
|
||||
explorer.files.get(0).unwrap().get_name(),
|
||||
|
@ -513,7 +513,7 @@ mod tests {
|
|||
make_fs_entry("src/", true),
|
||||
make_fs_entry_with_size("CONTRIBUTING.md", false, 256),
|
||||
]);
|
||||
explorer.sort_by(FileSorting::BySize);
|
||||
explorer.sort_by(FileSorting::Size);
|
||||
// Directory has size 4096
|
||||
assert_eq!(explorer.files.get(0).unwrap().get_name(), "src/");
|
||||
assert_eq!(explorer.files.get(1).unwrap().get_name(), "README.md");
|
||||
|
@ -536,7 +536,7 @@ mod tests {
|
|||
make_fs_entry("Cargo.lock", false),
|
||||
make_fs_entry("codecov.yml", false),
|
||||
]);
|
||||
explorer.sort_by(FileSorting::ByName);
|
||||
explorer.sort_by(FileSorting::Name);
|
||||
explorer.group_dirs_by(Some(GroupDirs::First));
|
||||
// First entry should be "docs"
|
||||
assert_eq!(explorer.files.get(0).unwrap().get_name(), "docs/");
|
||||
|
@ -563,7 +563,7 @@ mod tests {
|
|||
make_fs_entry("Cargo.lock", false),
|
||||
make_fs_entry("codecov.yml", false),
|
||||
]);
|
||||
explorer.sort_by(FileSorting::ByName);
|
||||
explorer.sort_by(FileSorting::Name);
|
||||
explorer.group_dirs_by(Some(GroupDirs::Last));
|
||||
// Last entry should be "src"
|
||||
assert_eq!(explorer.files.get(8).unwrap().get_name(), "docs/");
|
||||
|
@ -614,25 +614,25 @@ mod tests {
|
|||
#[test]
|
||||
fn test_fs_explorer_to_string_from_str_traits() {
|
||||
// File Sorting
|
||||
assert_eq!(FileSorting::ByCreationTime.to_string(), "by_creation_time");
|
||||
assert_eq!(FileSorting::ByModifyTime.to_string(), "by_mtime");
|
||||
assert_eq!(FileSorting::ByName.to_string(), "by_name");
|
||||
assert_eq!(FileSorting::BySize.to_string(), "by_size");
|
||||
assert_eq!(FileSorting::CreationTime.to_string(), "by_creation_time");
|
||||
assert_eq!(FileSorting::ModifyTime.to_string(), "by_mtime");
|
||||
assert_eq!(FileSorting::Name.to_string(), "by_name");
|
||||
assert_eq!(FileSorting::Size.to_string(), "by_size");
|
||||
assert_eq!(
|
||||
FileSorting::from_str("by_creation_time").ok().unwrap(),
|
||||
FileSorting::ByCreationTime
|
||||
FileSorting::CreationTime
|
||||
);
|
||||
assert_eq!(
|
||||
FileSorting::from_str("by_mtime").ok().unwrap(),
|
||||
FileSorting::ByModifyTime
|
||||
FileSorting::ModifyTime
|
||||
);
|
||||
assert_eq!(
|
||||
FileSorting::from_str("by_name").ok().unwrap(),
|
||||
FileSorting::ByName
|
||||
FileSorting::Name
|
||||
);
|
||||
assert_eq!(
|
||||
FileSorting::from_str("by_size").ok().unwrap(),
|
||||
FileSorting::BySize
|
||||
FileSorting::Size
|
||||
);
|
||||
assert!(FileSorting::from_str("omar").is_err());
|
||||
// Group dirs
|
||||
|
|
|
@ -115,7 +115,7 @@ impl BookmarksClient {
|
|||
if let Err(e) = key_storage.set_key(service_id, key.as_str()) {
|
||||
error!("Failed to set new key into storage: {}", e);
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
format!("Could not write key to storage: {}", e),
|
||||
));
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ impl BookmarksClient {
|
|||
_ => {
|
||||
error!("Failed to get key from storage: {}", e);
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
format!("Could not get key from storage: {}", e),
|
||||
));
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ impl BookmarksClient {
|
|||
Err(err) => {
|
||||
error!("Failed to write bookmarks: {}", err);
|
||||
Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ impl BookmarksClient {
|
|||
Err(err) => {
|
||||
error!("Failed to read bookmarks: {}", err);
|
||||
Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ impl BookmarksClient {
|
|||
match crypto::aes128_b64_decrypt(self.key.as_str(), secret) {
|
||||
Ok(txt) => Ok(txt),
|
||||
Err(err) => Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::SyntaxError,
|
||||
SerializerErrorKind::Syntax,
|
||||
err.to_string(),
|
||||
)),
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ impl ConfigClient {
|
|||
if let Err(err) = create_dir(ssh_key_dir) {
|
||||
error!("Failed to create SSH key dir: {}", err);
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
format!(
|
||||
"Could not create SSH key directory \"{}\": {}",
|
||||
ssh_key_dir.display(),
|
||||
|
@ -252,7 +252,7 @@ impl ConfigClient {
|
|||
) -> Result<(), SerializerError> {
|
||||
if self.degraded {
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::GenericError,
|
||||
SerializerErrorKind::Generic,
|
||||
String::from("Configuration won't be saved, since in degraded mode"),
|
||||
));
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ impl ConfigClient {
|
|||
pub fn del_ssh_key(&mut self, host: &str, username: &str) -> Result<(), SerializerError> {
|
||||
if self.degraded {
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::GenericError,
|
||||
SerializerErrorKind::Generic,
|
||||
String::from("Configuration won't be saved, since in degraded mode"),
|
||||
));
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ impl ConfigClient {
|
|||
pub fn write_config(&self) -> Result<(), SerializerError> {
|
||||
if self.degraded {
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::GenericError,
|
||||
SerializerErrorKind::Generic,
|
||||
String::from("Configuration won't be saved, since in degraded mode"),
|
||||
));
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ impl ConfigClient {
|
|||
Err(err) => {
|
||||
error!("Failed to write configuration file: {}", err);
|
||||
Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ impl ConfigClient {
|
|||
pub fn read_config(&mut self) -> Result<(), SerializerError> {
|
||||
if self.degraded {
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::GenericError,
|
||||
SerializerErrorKind::Generic,
|
||||
String::from("Configuration won't be loaded, since in degraded mode"),
|
||||
));
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ impl ConfigClient {
|
|||
Err(err) => {
|
||||
error!("Failed to read configuration: {}", err);
|
||||
Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ impl ConfigClient {
|
|||
/// Make serializer error from `std::io::Error`
|
||||
fn make_io_err(err: std::io::Error) -> Result<(), SerializerError> {
|
||||
Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ impl ThemeProvider {
|
|||
warn!("Configuration won't be loaded, since degraded; reloading default...");
|
||||
self.theme = Theme::default();
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::GenericError,
|
||||
SerializerErrorKind::Generic,
|
||||
String::from("Can't access theme file"),
|
||||
));
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl ThemeProvider {
|
|||
Err(err) => {
|
||||
error!("Failed to read theme: {}", err);
|
||||
Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ impl ThemeProvider {
|
|||
if self.degraded {
|
||||
warn!("Configuration won't be saved, since in degraded mode");
|
||||
return Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::GenericError,
|
||||
SerializerErrorKind::Generic,
|
||||
String::from("Can't access theme file"),
|
||||
));
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ impl ThemeProvider {
|
|||
Err(err) => {
|
||||
error!("Failed to write theme: {}", err);
|
||||
Err(SerializerError::new_ex(
|
||||
SerializerErrorKind::IoError,
|
||||
SerializerErrorKind::Io,
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ impl AuthActivity {
|
|||
// Iterate over kyes
|
||||
let name: Option<&String> = self.bookmarks_list.get(idx);
|
||||
if let Some(name) = name {
|
||||
bookmarks_cli.del_bookmark(&name);
|
||||
bookmarks_cli.del_bookmark(name);
|
||||
// Write bookmarks
|
||||
self.write_bookmarks();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ impl AuthActivity {
|
|||
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
|
||||
// Iterate over bookmarks
|
||||
if let Some(key) = self.bookmarks_list.get(idx) {
|
||||
if let Some(bookmark) = bookmarks_cli.get_bookmark(&key) {
|
||||
if let Some(bookmark) = bookmarks_cli.get_bookmark(key) {
|
||||
// Load parameters into components
|
||||
self.load_bookmark_into_gui(
|
||||
bookmark.0, bookmark.1, bookmark.2, bookmark.3, bookmark.4,
|
||||
|
@ -104,7 +104,7 @@ impl AuthActivity {
|
|||
if let Some(client) = self.bookmarks_client.as_mut() {
|
||||
let name: Option<&String> = self.recents_list.get(idx);
|
||||
if let Some(name) = name {
|
||||
client.del_recent(&name);
|
||||
client.del_recent(name);
|
||||
// Write bookmarks
|
||||
self.write_bookmarks();
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ impl FileTransferActivity {
|
|||
}
|
||||
|
||||
pub(crate) fn local_remove_file(&mut self, entry: &FsEntry) {
|
||||
match self.host.remove(&entry) {
|
||||
match self.host.remove(entry) {
|
||||
Ok(_) => {
|
||||
// Log
|
||||
self.log(
|
||||
|
@ -94,7 +94,7 @@ impl FileTransferActivity {
|
|||
}
|
||||
|
||||
pub(crate) fn remote_remove_file(&mut self, entry: &FsEntry) {
|
||||
match self.client.remove(&entry) {
|
||||
match self.client.remove(entry) {
|
||||
Ok(_) => {
|
||||
self.log(
|
||||
LogLevel::Info,
|
||||
|
|
|
@ -142,7 +142,7 @@ impl Browser {
|
|||
let mut builder: FileExplorerBuilder = FileExplorerBuilder::new();
|
||||
// Set common keys
|
||||
builder
|
||||
.with_file_sorting(FileSorting::ByName)
|
||||
.with_file_sorting(FileSorting::Name)
|
||||
.with_stack_size(16)
|
||||
.with_group_dirs(cli.get_group_dirs())
|
||||
.with_hidden_files(cli.get_show_hidden_files());
|
||||
|
@ -154,7 +154,7 @@ impl Browser {
|
|||
/// Build explorer reading from `ConfigClient`, for found result (has some differences)
|
||||
fn build_found_explorer() -> FileExplorer {
|
||||
FileExplorerBuilder::new()
|
||||
.with_file_sorting(FileSorting::ByName)
|
||||
.with_file_sorting(FileSorting::Name)
|
||||
.with_group_dirs(Some(GroupDirs::First))
|
||||
.with_hidden_files(true)
|
||||
.with_stack_size(0)
|
||||
|
|
|
@ -228,7 +228,7 @@ impl FileTransferActivity {
|
|||
///
|
||||
/// Returns config client reference
|
||||
fn config(&self) -> &ConfigClient {
|
||||
&self.context().config()
|
||||
self.context().config()
|
||||
}
|
||||
|
||||
/// ### theme
|
||||
|
|
|
@ -381,7 +381,7 @@ impl FileTransferActivity {
|
|||
}
|
||||
// Send entry; name is always None after first call
|
||||
self.filetransfer_send_recurse(
|
||||
&entry,
|
||||
entry,
|
||||
remote_path.as_path(),
|
||||
None,
|
||||
);
|
||||
|
@ -730,7 +730,7 @@ impl FileTransferActivity {
|
|||
// Receive entry; name is always None after first call
|
||||
// Local path becomes local_dir_path
|
||||
self.filetransfer_recv_recurse(
|
||||
&entry,
|
||||
entry,
|
||||
local_dir_path.as_path(),
|
||||
None,
|
||||
);
|
||||
|
|
|
@ -663,10 +663,10 @@ impl Update for FileTransferActivity {
|
|||
(COMPONENT_RADIO_SORTING, Msg::OnChange(Payload::One(Value::Usize(mode)))) => {
|
||||
// Get sorting mode
|
||||
let sorting: FileSorting = match mode {
|
||||
1 => FileSorting::ByModifyTime,
|
||||
2 => FileSorting::ByCreationTime,
|
||||
3 => FileSorting::BySize,
|
||||
_ => FileSorting::ByName,
|
||||
1 => FileSorting::ModifyTime,
|
||||
2 => FileSorting::CreationTime,
|
||||
3 => FileSorting::Size,
|
||||
_ => FileSorting::Name,
|
||||
};
|
||||
match self.browser.tab() {
|
||||
FileExplorerTab::Local => self.local_mut().sort_by(sorting),
|
||||
|
|
|
@ -770,10 +770,10 @@ impl FileTransferActivity {
|
|||
_ => panic!("You can't mount file sorting when in found result"),
|
||||
};
|
||||
let index: usize = match sorting {
|
||||
FileSorting::ByCreationTime => 2,
|
||||
FileSorting::ByModifyTime => 1,
|
||||
FileSorting::ByName => 0,
|
||||
FileSorting::BySize => 3,
|
||||
FileSorting::CreationTime => 2,
|
||||
FileSorting::ModifyTime => 1,
|
||||
FileSorting::Name => 0,
|
||||
FileSorting::Size => 3,
|
||||
};
|
||||
self.view.mount(
|
||||
super::COMPONENT_RADIO_SORTING,
|
||||
|
@ -1280,10 +1280,10 @@ impl FileTransferActivity {
|
|||
|
||||
fn get_file_sorting_str(mode: FileSorting) -> &'static str {
|
||||
match mode {
|
||||
FileSorting::ByName => "By name",
|
||||
FileSorting::ByCreationTime => "By creation time",
|
||||
FileSorting::ByModifyTime => "By modify time",
|
||||
FileSorting::BySize => "By size",
|
||||
FileSorting::Name => "By name",
|
||||
FileSorting::CreationTime => "By creation time",
|
||||
FileSorting::ModifyTime => "By modify time",
|
||||
FileSorting::Size => "By size",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ impl SetupActivity {
|
|||
}
|
||||
|
||||
fn config(&self) -> &ConfigClient {
|
||||
&self.context().config()
|
||||
self.context().config()
|
||||
}
|
||||
|
||||
fn config_mut(&mut self) -> &mut ConfigClient {
|
||||
|
|
Loading…
Reference in a new issue