This commit is contained in:
veeso
2021-08-10 22:27:20 +02:00
parent 6cfac57162
commit 764cca73d1
19 changed files with 104 additions and 100 deletions

View File

@@ -1,6 +1,7 @@
# Changelog # Changelog
- [Changelog](#changelog) - [Changelog](#changelog)
- [0.7.0](#070)
- [0.6.0](#060) - [0.6.0](#060)
- [0.5.1](#051) - [0.5.1](#051)
- [0.5.0](#050) - [0.5.0](#050)
@@ -19,6 +20,12 @@
--- ---
## 0.7.0
Released on ??
> 🍁 Autumn update 🍇
## 0.6.0 ## 0.6.0
Released on 23/07/2021 Released on 23/07/2021

View File

@@ -188,7 +188,7 @@ impl ActivityManager {
}; };
// If ft params is None, return None // If ft params is None, return None
let ft_params: &FileTransferParams = match ctx.ft_params() { let ft_params: &FileTransferParams = match ctx.ft_params() {
Some(ft_params) => &ft_params, Some(ft_params) => ft_params,
None => { None => {
error!("Failed to start FileTransferActivity: file transfer params is None"); error!("Failed to start FileTransferActivity: file transfer params is None");
return None; return None;

View File

@@ -44,13 +44,13 @@ pub struct SerializerError {
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum SerializerErrorKind { pub enum SerializerErrorKind {
#[error("Operation failed")] #[error("Operation failed")]
GenericError, Generic,
#[error("IO error")] #[error("IO error")]
IoError, Io,
#[error("Serialization error")] #[error("Serialization error")]
SerializationError, Serialization,
#[error("Syntax error")] #[error("Syntax error")]
SyntaxError, Syntax,
} }
impl SerializerError { impl SerializerError {
@@ -92,7 +92,7 @@ where
Ok(dt) => dt, Ok(dt) => dt,
Err(err) => { Err(err) => {
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::SerializationError, SerializerErrorKind::Serialization,
err.to_string(), err.to_string(),
)) ))
} }
@@ -102,7 +102,7 @@ where
match writable.write_all(data.as_bytes()) { match writable.write_all(data.as_bytes()) {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(err) => Err(SerializerError::new_ex( Err(err) => Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)), )),
} }
@@ -119,7 +119,7 @@ where
let mut data: String = String::new(); let mut data: String = String::new();
if let Err(err) = readable.read_to_string(&mut data) { if let Err(err) = readable.read_to_string(&mut data) {
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)); ));
} }
@@ -131,7 +131,7 @@ where
Ok(deserialized) Ok(deserialized)
} }
Err(err) => Err(SerializerError::new_ex( Err(err) => Err(SerializerError::new_ex(
SerializerErrorKind::SyntaxError, SerializerErrorKind::Syntax,
err.to_string(), err.to_string(),
)), )),
} }
@@ -154,11 +154,11 @@ mod tests {
#[test] #[test]
fn test_config_serialization_errors() { 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!(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::SyntaxError, 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),
@@ -166,20 +166,17 @@ mod tests {
); );
// Fmt // Fmt
assert_eq!( assert_eq!(
format!( format!("{}", SerializerError::new(SerializerErrorKind::Generic)),
"{}",
SerializerError::new(SerializerErrorKind::GenericError)
),
String::from("Operation failed") String::from("Operation failed")
); );
assert_eq!( assert_eq!(
format!("{}", SerializerError::new(SerializerErrorKind::IoError)), format!("{}", SerializerError::new(SerializerErrorKind::Io)),
String::from("IO error") String::from("IO error")
); );
assert_eq!( assert_eq!(
format!( format!(
"{}", "{}",
SerializerError::new(SerializerErrorKind::SerializationError) SerializerError::new(SerializerErrorKind::Serialization)
), ),
String::from("Serialization error") String::from("Serialization error")
); );

View File

@@ -189,7 +189,7 @@ impl FtpFileTransfer {
FsEntry::Directory(FsDirectory { FsEntry::Directory(FsDirectory {
name: p name: p
.file_name() .file_name()
.unwrap_or(&std::ffi::OsStr::new("")) .unwrap_or_else(|| std::ffi::OsStr::new(""))
.to_string_lossy() .to_string_lossy()
.to_string(), .to_string(),
abs_path: p.clone(), abs_path: p.clone(),
@@ -206,7 +206,7 @@ impl FtpFileTransfer {
false => FsEntry::File(FsFile { false => FsEntry::File(FsFile {
name: p name: p
.file_name() .file_name()
.unwrap_or(&std::ffi::OsStr::new("")) .unwrap_or_else(|| std::ffi::OsStr::new(""))
.to_string_lossy() .to_string_lossy()
.to_string(), .to_string(),
abs_path: p.clone(), abs_path: p.clone(),
@@ -659,7 +659,7 @@ impl FileTransfer for FtpFileTransfer {
// Remove recursively files // Remove recursively files
debug!("Removing {} entries from directory...", files.len()); debug!("Removing {} entries from directory...", files.len());
for file in files.iter() { for file in files.iter() {
if let Err(err) = self.remove(&file) { if let Err(err) = self.remove(file) {
return Err(FileTransferError::new_ex( return Err(FileTransferError::new_ex(
FileTransferErrorType::PexError, FileTransferErrorType::PexError,
err.to_string(), err.to_string(),

View File

@@ -169,7 +169,7 @@ impl ScpFileTransfer {
// Get symlink; PATH mustn't be equal to filename // Get symlink; PATH mustn't be equal to filename
let symlink: Option<Box<FsEntry>> = match symlink_path { let symlink: Option<Box<FsEntry>> = match symlink_path {
None => None, 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() == file_name.as_str()
{ {
// If name is equal, don't stat path; otherwise it would get stuck // If name is equal, don't stat path; otherwise it would get stuck
@@ -339,7 +339,7 @@ impl FileTransfer for ScpFileTransfer {
// Try addresses // Try addresses
for socket_addr in socket_addresses.iter() { for socket_addr in socket_addresses.iter() {
debug!("Trying socket address {}", socket_addr); 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) => { Ok(stream) => {
debug!("{} succeded", socket_addr); debug!("{} succeded", socket_addr);
tcp = Some(stream); tcp = Some(stream);

View File

@@ -282,7 +282,7 @@ impl FileTransfer for SftpFileTransfer {
// Try addresses // Try addresses
for socket_addr in socket_addresses.iter() { for socket_addr in socket_addresses.iter() {
debug!("Trying socket address {}", socket_addr); 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) => { Ok(stream) => {
tcp = Some(stream); tcp = Some(stream);
break; break;
@@ -602,7 +602,7 @@ impl FileTransfer for SftpFileTransfer {
// Get directory files // Get directory files
let directory_content: Vec<FsEntry> = self.list_dir(d.abs_path.as_path())?; let directory_content: Vec<FsEntry> = self.list_dir(d.abs_path.as_path())?;
for entry in directory_content.iter() { for entry in directory_content.iter() {
if let Err(err) = self.remove(&entry) { if let Err(err) = self.remove(entry) {
return Err(err); return Err(err);
} }
} }

View File

@@ -124,7 +124,7 @@ mod tests {
let explorer: FileExplorer = FileExplorerBuilder::new().build(); let explorer: FileExplorer = FileExplorerBuilder::new().build();
// Verify // Verify
assert!(!explorer.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES)); 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.group_dirs, None);
assert_eq!(explorer.stack_size, 16); assert_eq!(explorer.stack_size, 16);
} }
@@ -132,7 +132,7 @@ mod tests {
#[test] #[test]
fn test_fs_explorer_builder_new_all() { fn test_fs_explorer_builder_new_all() {
let explorer: FileExplorer = FileExplorerBuilder::new() let explorer: FileExplorer = FileExplorerBuilder::new()
.with_file_sorting(FileSorting::ByModifyTime) .with_file_sorting(FileSorting::ModifyTime)
.with_group_dirs(Some(GroupDirs::First)) .with_group_dirs(Some(GroupDirs::First))
.with_hidden_files(true) .with_hidden_files(true)
.with_stack_size(24) .with_stack_size(24)
@@ -140,7 +140,7 @@ mod tests {
.build(); .build();
// Verify // Verify
assert!(explorer.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES)); 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.group_dirs, Some(GroupDirs::First));
assert_eq!(explorer.stack_size, 24); assert_eq!(explorer.stack_size, 24);
} }

View File

@@ -52,10 +52,10 @@ bitflags! {
/// FileSorting defines the criteria for sorting files /// FileSorting defines the criteria for sorting files
#[derive(Copy, Clone, PartialEq, std::fmt::Debug)] #[derive(Copy, Clone, PartialEq, std::fmt::Debug)]
pub enum FileSorting { pub enum FileSorting {
ByName, Name,
ByModifyTime, ModifyTime,
ByCreationTime, CreationTime,
BySize, Size,
} }
/// ## GroupDirs /// ## GroupDirs
@@ -87,7 +87,7 @@ impl Default for FileExplorer {
wrkdir: PathBuf::from("/"), wrkdir: PathBuf::from("/"),
dirstack: VecDeque::with_capacity(16), dirstack: VecDeque::with_capacity(16),
stack_size: 16, stack_size: 16,
file_sorting: FileSorting::ByName, file_sorting: FileSorting::Name,
group_dirs: None, group_dirs: None,
opts: ExplorerOpts::empty(), opts: ExplorerOpts::empty(),
fmt: Formatter::default(), fmt: Formatter::default(),
@@ -237,10 +237,10 @@ impl FileExplorer {
fn sort(&mut self) { fn sort(&mut self) {
// Choose sorting method // Choose sorting method
match &self.file_sorting { match &self.file_sorting {
FileSorting::ByName => self.sort_files_by_name(), FileSorting::Name => self.sort_files_by_name(),
FileSorting::ByCreationTime => self.sort_files_by_creation_time(), FileSorting::CreationTime => self.sort_files_by_creation_time(),
FileSorting::ByModifyTime => self.sort_files_by_mtime(), FileSorting::ModifyTime => self.sort_files_by_mtime(),
FileSorting::BySize => self.sort_files_by_size(), FileSorting::Size => self.sort_files_by_size(),
} }
// Directories first (NOTE: MUST COME AFTER OTHER SORTING) // Directories first (NOTE: MUST COME AFTER OTHER SORTING)
// Group directories if necessary // Group directories if necessary
@@ -318,10 +318,10 @@ impl FileExplorer {
impl ToString for FileSorting { impl ToString for FileSorting {
fn to_string(&self) -> String { fn to_string(&self) -> String {
String::from(match self { String::from(match self {
FileSorting::ByCreationTime => "by_creation_time", FileSorting::CreationTime => "by_creation_time",
FileSorting::ByModifyTime => "by_mtime", FileSorting::ModifyTime => "by_mtime",
FileSorting::ByName => "by_name", FileSorting::Name => "by_name",
FileSorting::BySize => "by_size", FileSorting::Size => "by_size",
}) })
} }
} }
@@ -330,10 +330,10 @@ impl FromStr for FileSorting {
type Err = (); type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_ascii_lowercase().as_str() { match s.to_ascii_lowercase().as_str() {
"by_creation_time" => Ok(FileSorting::ByCreationTime), "by_creation_time" => Ok(FileSorting::CreationTime),
"by_mtime" => Ok(FileSorting::ByModifyTime), "by_mtime" => Ok(FileSorting::ModifyTime),
"by_name" => Ok(FileSorting::ByName), "by_name" => Ok(FileSorting::Name),
"by_size" => Ok(FileSorting::BySize), "by_size" => Ok(FileSorting::Size),
_ => Err(()), _ => Err(()),
} }
} }
@@ -380,8 +380,8 @@ mod tests {
assert_eq!(explorer.wrkdir, PathBuf::from("/")); assert_eq!(explorer.wrkdir, PathBuf::from("/"));
assert_eq!(explorer.stack_size, 16); assert_eq!(explorer.stack_size, 16);
assert_eq!(explorer.group_dirs, None); assert_eq!(explorer.group_dirs, None);
assert_eq!(explorer.file_sorting, FileSorting::ByName); assert_eq!(explorer.file_sorting, FileSorting::Name);
assert_eq!(explorer.get_file_sorting(), FileSorting::ByName); assert_eq!(explorer.get_file_sorting(), FileSorting::Name);
} }
#[test] #[test]
@@ -459,7 +459,7 @@ mod tests {
make_fs_entry("Cargo.lock", false), make_fs_entry("Cargo.lock", false),
make_fs_entry("codecov.yml", false), make_fs_entry("codecov.yml", false),
]); ]);
explorer.sort_by(FileSorting::ByName); explorer.sort_by(FileSorting::Name);
// First entry should be "Cargo.lock" // First entry should be "Cargo.lock"
assert_eq!(explorer.files.get(0).unwrap().get_name(), "Cargo.lock"); assert_eq!(explorer.files.get(0).unwrap().get_name(), "Cargo.lock");
// Last should be "src/" // Last should be "src/"
@@ -475,7 +475,7 @@ mod tests {
let entry2: FsEntry = make_fs_entry("CODE_OF_CONDUCT.md", false); let entry2: FsEntry = make_fs_entry("CODE_OF_CONDUCT.md", false);
// Create files (files are then sorted by name) // Create files (files are then sorted by name)
explorer.set_files(vec![entry1, entry2]); explorer.set_files(vec![entry1, entry2]);
explorer.sort_by(FileSorting::ByModifyTime); explorer.sort_by(FileSorting::ModifyTime);
// First entry should be "CODE_OF_CONDUCT.md" // First entry should be "CODE_OF_CONDUCT.md"
assert_eq!( assert_eq!(
explorer.files.get(0).unwrap().get_name(), explorer.files.get(0).unwrap().get_name(),
@@ -494,7 +494,7 @@ mod tests {
let entry2: FsEntry = make_fs_entry("CODE_OF_CONDUCT.md", false); let entry2: FsEntry = make_fs_entry("CODE_OF_CONDUCT.md", false);
// Create files (files are then sorted by name) // Create files (files are then sorted by name)
explorer.set_files(vec![entry1, entry2]); explorer.set_files(vec![entry1, entry2]);
explorer.sort_by(FileSorting::ByCreationTime); explorer.sort_by(FileSorting::CreationTime);
// First entry should be "CODE_OF_CONDUCT.md" // First entry should be "CODE_OF_CONDUCT.md"
assert_eq!( assert_eq!(
explorer.files.get(0).unwrap().get_name(), explorer.files.get(0).unwrap().get_name(),
@@ -513,7 +513,7 @@ mod tests {
make_fs_entry("src/", true), make_fs_entry("src/", true),
make_fs_entry_with_size("CONTRIBUTING.md", false, 256), make_fs_entry_with_size("CONTRIBUTING.md", false, 256),
]); ]);
explorer.sort_by(FileSorting::BySize); explorer.sort_by(FileSorting::Size);
// Directory has size 4096 // Directory has size 4096
assert_eq!(explorer.files.get(0).unwrap().get_name(), "src/"); assert_eq!(explorer.files.get(0).unwrap().get_name(), "src/");
assert_eq!(explorer.files.get(1).unwrap().get_name(), "README.md"); 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("Cargo.lock", false),
make_fs_entry("codecov.yml", false), make_fs_entry("codecov.yml", false),
]); ]);
explorer.sort_by(FileSorting::ByName); explorer.sort_by(FileSorting::Name);
explorer.group_dirs_by(Some(GroupDirs::First)); explorer.group_dirs_by(Some(GroupDirs::First));
// First entry should be "docs" // First entry should be "docs"
assert_eq!(explorer.files.get(0).unwrap().get_name(), "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("Cargo.lock", false),
make_fs_entry("codecov.yml", false), make_fs_entry("codecov.yml", false),
]); ]);
explorer.sort_by(FileSorting::ByName); explorer.sort_by(FileSorting::Name);
explorer.group_dirs_by(Some(GroupDirs::Last)); explorer.group_dirs_by(Some(GroupDirs::Last));
// Last entry should be "src" // Last entry should be "src"
assert_eq!(explorer.files.get(8).unwrap().get_name(), "docs/"); assert_eq!(explorer.files.get(8).unwrap().get_name(), "docs/");
@@ -614,25 +614,25 @@ mod tests {
#[test] #[test]
fn test_fs_explorer_to_string_from_str_traits() { fn test_fs_explorer_to_string_from_str_traits() {
// File Sorting // File Sorting
assert_eq!(FileSorting::ByCreationTime.to_string(), "by_creation_time"); assert_eq!(FileSorting::CreationTime.to_string(), "by_creation_time");
assert_eq!(FileSorting::ByModifyTime.to_string(), "by_mtime"); assert_eq!(FileSorting::ModifyTime.to_string(), "by_mtime");
assert_eq!(FileSorting::ByName.to_string(), "by_name"); assert_eq!(FileSorting::Name.to_string(), "by_name");
assert_eq!(FileSorting::BySize.to_string(), "by_size"); assert_eq!(FileSorting::Size.to_string(), "by_size");
assert_eq!( assert_eq!(
FileSorting::from_str("by_creation_time").ok().unwrap(), FileSorting::from_str("by_creation_time").ok().unwrap(),
FileSorting::ByCreationTime FileSorting::CreationTime
); );
assert_eq!( assert_eq!(
FileSorting::from_str("by_mtime").ok().unwrap(), FileSorting::from_str("by_mtime").ok().unwrap(),
FileSorting::ByModifyTime FileSorting::ModifyTime
); );
assert_eq!( assert_eq!(
FileSorting::from_str("by_name").ok().unwrap(), FileSorting::from_str("by_name").ok().unwrap(),
FileSorting::ByName FileSorting::Name
); );
assert_eq!( assert_eq!(
FileSorting::from_str("by_size").ok().unwrap(), FileSorting::from_str("by_size").ok().unwrap(),
FileSorting::BySize FileSorting::Size
); );
assert!(FileSorting::from_str("omar").is_err()); assert!(FileSorting::from_str("omar").is_err());
// Group dirs // Group dirs

View File

@@ -115,7 +115,7 @@ impl BookmarksClient {
if let Err(e) = key_storage.set_key(service_id, key.as_str()) { if let Err(e) = key_storage.set_key(service_id, key.as_str()) {
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::IoError, SerializerErrorKind::Io,
format!("Could not write key to storage: {}", e), format!("Could not write key to storage: {}", e),
)); ));
} }
@@ -125,7 +125,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::IoError, SerializerErrorKind::Io,
format!("Could not get key from storage: {}", e), format!("Could not get key from storage: {}", e),
)); ));
} }
@@ -328,7 +328,7 @@ impl BookmarksClient {
Err(err) => { Err(err) => {
error!("Failed to write bookmarks: {}", err); error!("Failed to write bookmarks: {}", err);
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)) ))
} }
@@ -358,7 +358,7 @@ impl BookmarksClient {
Err(err) => { Err(err) => {
error!("Failed to read bookmarks: {}", err); error!("Failed to read bookmarks: {}", err);
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)) ))
} }
@@ -407,7 +407,7 @@ impl BookmarksClient {
match crypto::aes128_b64_decrypt(self.key.as_str(), secret) { match crypto::aes128_b64_decrypt(self.key.as_str(), secret) {
Ok(txt) => Ok(txt), Ok(txt) => Ok(txt),
Err(err) => Err(SerializerError::new_ex( Err(err) => Err(SerializerError::new_ex(
SerializerErrorKind::SyntaxError, SerializerErrorKind::Syntax,
err.to_string(), err.to_string(),
)), )),
} }

View File

@@ -76,7 +76,7 @@ impl ConfigClient {
if let Err(err) = create_dir(ssh_key_dir) { if let Err(err) = create_dir(ssh_key_dir) {
error!("Failed to create SSH key dir: {}", err); error!("Failed to create SSH key dir: {}", err);
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
format!( format!(
"Could not create SSH key directory \"{}\": {}", "Could not create SSH key directory \"{}\": {}",
ssh_key_dir.display(), ssh_key_dir.display(),
@@ -252,7 +252,7 @@ impl ConfigClient {
) -> Result<(), SerializerError> { ) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::GenericError, SerializerErrorKind::Generic,
String::from("Configuration won't be saved, since in degraded mode"), 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> { pub fn del_ssh_key(&mut self, host: &str, username: &str) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::GenericError, SerializerErrorKind::Generic,
String::from("Configuration won't be saved, since in degraded mode"), String::from("Configuration won't be saved, since in degraded mode"),
)); ));
} }
@@ -351,7 +351,7 @@ impl ConfigClient {
pub fn write_config(&self) -> Result<(), SerializerError> { pub fn write_config(&self) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::GenericError, SerializerErrorKind::Generic,
String::from("Configuration won't be saved, since in degraded mode"), String::from("Configuration won't be saved, since in degraded mode"),
)); ));
} }
@@ -366,7 +366,7 @@ impl ConfigClient {
Err(err) => { Err(err) => {
error!("Failed to write configuration file: {}", err); error!("Failed to write configuration file: {}", err);
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)) ))
} }
@@ -379,7 +379,7 @@ impl ConfigClient {
pub fn read_config(&mut self) -> Result<(), SerializerError> { pub fn read_config(&mut self) -> Result<(), SerializerError> {
if self.degraded { if self.degraded {
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::GenericError, SerializerErrorKind::Generic,
String::from("Configuration won't be loaded, since in degraded mode"), String::from("Configuration won't be loaded, since in degraded mode"),
)); ));
} }
@@ -401,7 +401,7 @@ impl ConfigClient {
Err(err) => { Err(err) => {
error!("Failed to read configuration: {}", err); error!("Failed to read configuration: {}", err);
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)) ))
} }
@@ -432,7 +432,7 @@ impl ConfigClient {
/// Make serializer error from `std::io::Error` /// Make serializer error from `std::io::Error`
fn make_io_err(err: std::io::Error) -> Result<(), SerializerError> { fn make_io_err(err: std::io::Error) -> Result<(), SerializerError> {
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)) ))
} }

View File

@@ -116,7 +116,7 @@ impl ThemeProvider {
warn!("Configuration won't be loaded, since degraded; reloading default..."); warn!("Configuration won't be loaded, since degraded; reloading default...");
self.theme = Theme::default(); self.theme = Theme::default();
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::GenericError, SerializerErrorKind::Generic,
String::from("Can't access theme file"), String::from("Can't access theme file"),
)); ));
} }
@@ -139,7 +139,7 @@ impl ThemeProvider {
Err(err) => { Err(err) => {
error!("Failed to read theme: {}", err); error!("Failed to read theme: {}", err);
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)) ))
} }
@@ -153,7 +153,7 @@ impl ThemeProvider {
if self.degraded { if self.degraded {
warn!("Configuration won't be saved, since in degraded mode"); warn!("Configuration won't be saved, since in degraded mode");
return Err(SerializerError::new_ex( return Err(SerializerError::new_ex(
SerializerErrorKind::GenericError, SerializerErrorKind::Generic,
String::from("Can't access theme file"), String::from("Can't access theme file"),
)); ));
} }
@@ -169,7 +169,7 @@ impl ThemeProvider {
Err(err) => { Err(err) => {
error!("Failed to write theme: {}", err); error!("Failed to write theme: {}", err);
Err(SerializerError::new_ex( Err(SerializerError::new_ex(
SerializerErrorKind::IoError, SerializerErrorKind::Io,
err.to_string(), err.to_string(),
)) ))
} }

View File

@@ -44,7 +44,7 @@ impl AuthActivity {
// Iterate over kyes // Iterate over kyes
let name: Option<&String> = self.bookmarks_list.get(idx); let name: Option<&String> = self.bookmarks_list.get(idx);
if let Some(name) = name { if let Some(name) = name {
bookmarks_cli.del_bookmark(&name); bookmarks_cli.del_bookmark(name);
// Write bookmarks // Write bookmarks
self.write_bookmarks(); self.write_bookmarks();
} }
@@ -60,7 +60,7 @@ impl AuthActivity {
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() { if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
// Iterate over bookmarks // Iterate over bookmarks
if let Some(key) = self.bookmarks_list.get(idx) { 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 // Load parameters into components
self.load_bookmark_into_gui( self.load_bookmark_into_gui(
bookmark.0, bookmark.1, bookmark.2, bookmark.3, bookmark.4, 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() { if let Some(client) = self.bookmarks_client.as_mut() {
let name: Option<&String> = self.recents_list.get(idx); let name: Option<&String> = self.recents_list.get(idx);
if let Some(name) = name { if let Some(name) = name {
client.del_recent(&name); client.del_recent(name);
// Write bookmarks // Write bookmarks
self.write_bookmarks(); self.write_bookmarks();
} }

View File

@@ -72,7 +72,7 @@ impl FileTransferActivity {
} }
pub(crate) fn local_remove_file(&mut self, entry: &FsEntry) { pub(crate) fn local_remove_file(&mut self, entry: &FsEntry) {
match self.host.remove(&entry) { match self.host.remove(entry) {
Ok(_) => { Ok(_) => {
// Log // Log
self.log( self.log(
@@ -94,7 +94,7 @@ impl FileTransferActivity {
} }
pub(crate) fn remote_remove_file(&mut self, entry: &FsEntry) { pub(crate) fn remote_remove_file(&mut self, entry: &FsEntry) {
match self.client.remove(&entry) { match self.client.remove(entry) {
Ok(_) => { Ok(_) => {
self.log( self.log(
LogLevel::Info, LogLevel::Info,

View File

@@ -142,7 +142,7 @@ impl Browser {
let mut builder: FileExplorerBuilder = FileExplorerBuilder::new(); let mut builder: FileExplorerBuilder = FileExplorerBuilder::new();
// Set common keys // Set common keys
builder builder
.with_file_sorting(FileSorting::ByName) .with_file_sorting(FileSorting::Name)
.with_stack_size(16) .with_stack_size(16)
.with_group_dirs(cli.get_group_dirs()) .with_group_dirs(cli.get_group_dirs())
.with_hidden_files(cli.get_show_hidden_files()); .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) /// Build explorer reading from `ConfigClient`, for found result (has some differences)
fn build_found_explorer() -> FileExplorer { fn build_found_explorer() -> FileExplorer {
FileExplorerBuilder::new() FileExplorerBuilder::new()
.with_file_sorting(FileSorting::ByName) .with_file_sorting(FileSorting::Name)
.with_group_dirs(Some(GroupDirs::First)) .with_group_dirs(Some(GroupDirs::First))
.with_hidden_files(true) .with_hidden_files(true)
.with_stack_size(0) .with_stack_size(0)

View File

@@ -228,7 +228,7 @@ impl FileTransferActivity {
/// ///
/// Returns config client reference /// Returns config client reference
fn config(&self) -> &ConfigClient { fn config(&self) -> &ConfigClient {
&self.context().config() self.context().config()
} }
/// ### theme /// ### theme

View File

@@ -381,7 +381,7 @@ impl FileTransferActivity {
} }
// Send entry; name is always None after first call // Send entry; name is always None after first call
self.filetransfer_send_recurse( self.filetransfer_send_recurse(
&entry, entry,
remote_path.as_path(), remote_path.as_path(),
None, None,
); );
@@ -730,7 +730,7 @@ impl FileTransferActivity {
// Receive entry; name is always None after first call // Receive entry; name is always None after first call
// Local path becomes local_dir_path // Local path becomes local_dir_path
self.filetransfer_recv_recurse( self.filetransfer_recv_recurse(
&entry, entry,
local_dir_path.as_path(), local_dir_path.as_path(),
None, None,
); );

View File

@@ -663,10 +663,10 @@ impl Update for FileTransferActivity {
(COMPONENT_RADIO_SORTING, Msg::OnChange(Payload::One(Value::Usize(mode)))) => { (COMPONENT_RADIO_SORTING, Msg::OnChange(Payload::One(Value::Usize(mode)))) => {
// Get sorting mode // Get sorting mode
let sorting: FileSorting = match mode { let sorting: FileSorting = match mode {
1 => FileSorting::ByModifyTime, 1 => FileSorting::ModifyTime,
2 => FileSorting::ByCreationTime, 2 => FileSorting::CreationTime,
3 => FileSorting::BySize, 3 => FileSorting::Size,
_ => FileSorting::ByName, _ => FileSorting::Name,
}; };
match self.browser.tab() { match self.browser.tab() {
FileExplorerTab::Local => self.local_mut().sort_by(sorting), FileExplorerTab::Local => self.local_mut().sort_by(sorting),

View File

@@ -770,10 +770,10 @@ impl FileTransferActivity {
_ => panic!("You can't mount file sorting when in found result"), _ => panic!("You can't mount file sorting when in found result"),
}; };
let index: usize = match sorting { let index: usize = match sorting {
FileSorting::ByCreationTime => 2, FileSorting::CreationTime => 2,
FileSorting::ByModifyTime => 1, FileSorting::ModifyTime => 1,
FileSorting::ByName => 0, FileSorting::Name => 0,
FileSorting::BySize => 3, FileSorting::Size => 3,
}; };
self.view.mount( self.view.mount(
super::COMPONENT_RADIO_SORTING, super::COMPONENT_RADIO_SORTING,
@@ -1280,10 +1280,10 @@ impl FileTransferActivity {
fn get_file_sorting_str(mode: FileSorting) -> &'static str { fn get_file_sorting_str(mode: FileSorting) -> &'static str {
match mode { match mode {
FileSorting::ByName => "By name", FileSorting::Name => "By name",
FileSorting::ByCreationTime => "By creation time", FileSorting::CreationTime => "By creation time",
FileSorting::ByModifyTime => "By modify time", FileSorting::ModifyTime => "By modify time",
FileSorting::BySize => "By size", FileSorting::Size => "By size",
} }
} }

View File

@@ -152,7 +152,7 @@ impl SetupActivity {
} }
fn config(&self) -> &ConfigClient { fn config(&self) -> &ConfigClient {
&self.context().config() self.context().config()
} }
fn config_mut(&mut self) -> &mut ConfigClient { fn config_mut(&mut self) -> &mut ConfigClient {