1
0
Fork 0
mirror of synced 2024-06-15 00:45:29 +12:00

Copy Clone

This commit is contained in:
Rafał Mikrut 2023-02-18 06:54:25 +01:00
parent 314e4b1dfe
commit 208529cf98
15 changed files with 35 additions and 22 deletions

View file

@ -43,7 +43,7 @@ pub enum SearchMode {
SmallestFiles,
}
#[derive(Eq, PartialEq, Clone, Debug)]
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
pub enum DeleteMethod {
None,
Delete,
@ -394,7 +394,7 @@ impl BigFile {
match self.delete_method {
DeleteMethod::Delete => {
for (_, file_entry) in &self.big_files {
if fs::remove_file(file_entry.path.clone()).is_err() {
if fs::remove_file(&file_entry.path).is_err() {
self.text_messages.warnings.push(file_entry.path.display().to_string());
}
}

View file

@ -34,7 +34,7 @@ pub struct ProgressData {
pub files_to_check: usize,
}
#[derive(Eq, PartialEq, Clone, Debug)]
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
pub enum DeleteMethod {
None,
Delete,

View file

@ -53,7 +53,7 @@ pub struct SymlinkInfo {
pub type_of_error: ErrorType,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Copy)]
pub enum ErrorType {
InfiniteRecursion,
NonExistentFile,
@ -87,7 +87,7 @@ pub enum Collect {
Files,
}
#[derive(Eq, PartialEq)]
#[derive(Eq, PartialEq, Copy, Clone)]
enum EntryType {
File,
Dir,

View file

@ -49,7 +49,7 @@ impl HashType {
}
}
#[derive(Eq, PartialEq, Clone, Debug)]
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
pub enum DeleteMethod {
None,
AllExceptNewest,

View file

@ -15,7 +15,7 @@ use crate::common_items::ExcludedItems;
use crate::common_messages::Messages;
use crate::common_traits::*;
#[derive(Eq, PartialEq, Clone, Debug)]
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
pub enum DeleteMethod {
None,
Delete,

View file

@ -24,7 +24,7 @@ use crate::common_items::ExcludedItems;
use crate::common_messages::Messages;
use crate::common_traits::*;
#[derive(Eq, PartialEq, Clone, Debug)]
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
pub enum DeleteMethod {
None,
Delete,
@ -666,7 +666,7 @@ impl SameMusic {
for file_entry in vec_file_entry {
let thing = file_entry.genre.trim().to_lowercase();
if !thing.is_empty() {
hash_map.entry(thing.clone()).or_insert_with(Vec::new).push(file_entry);
hash_map.entry(thing).or_insert_with(Vec::new).push(file_entry);
}
}
for (_title, vec_file_entry) in hash_map {

View file

@ -59,7 +59,7 @@ pub struct FileEntry {
}
/// Used by CLI tool when we cannot use directly values
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Copy)]
pub enum SimilarityPreset {
Original,
VeryHigh,

View file

@ -391,6 +391,7 @@ impl SimilarVideos {
if self.excluded_items.is_excluded(&current_file_name) {
continue 'dir;
}
let current_file_name_str = current_file_name.to_string_lossy().to_string();
let fe: FileEntry = FileEntry {
path: current_file_name.clone(),
@ -401,7 +402,7 @@ impl SimilarVideos {
Err(_inspected) => {
warnings.push(flc!(
"core_file_modified_before_epoch",
generate_translation_hashmap(vec![("name", current_file_name.display().to_string())])
generate_translation_hashmap(vec![("name", current_file_name_str.clone())])
));
0
}
@ -409,7 +410,7 @@ impl SimilarVideos {
Err(e) => {
warnings.push(flc!(
"core_file_no_modification_date",
generate_translation_hashmap(vec![("name", current_file_name.display().to_string()), ("reason", e.to_string())])
generate_translation_hashmap(vec![("name", current_file_name_str.clone()), ("reason", e.to_string())])
));
0
}
@ -418,7 +419,7 @@ impl SimilarVideos {
error: String::new(),
};
fe_result.push((current_file_name.to_string_lossy().to_string(), fe));
fe_result.push((current_file_name_str, fe));
}
}
}

View file

@ -26,7 +26,7 @@ pub struct ProgressData {
pub files_checked: usize,
}
#[derive(Eq, PartialEq, Clone, Debug)]
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
pub enum DeleteMethod {
None,
Delete,

View file

@ -13,7 +13,7 @@ use crate::localizer_core::generate_translation_hashmap;
use crate::notebook_enums::*;
use crate::notebook_info::NOTEBOOKS_INFO;
#[derive(PartialEq, Eq)]
#[derive(PartialEq, Eq, Copy, Clone)]
enum TypeOfTool {
Hardlinking,
Symlinking,

View file

@ -34,7 +34,7 @@ fn show_required_popovers(popovers_select: &GuiSelectPopovers, current_mode: &No
let separator_select_image_size = popovers_select.separator_select_image_size.clone();
let separator_select_reverse = popovers_select.separator_select_reverse.clone();
let arr = &NOTEBOOKS_INFO[current_mode.clone() as usize].available_modes;
let arr = &NOTEBOOKS_INFO[*current_mode as usize].available_modes;
if arr.contains(&PopoverTypes::All) {
buttons_popover_select_all.show();

View file

@ -155,7 +155,7 @@ impl GuiData {
temp_hashmap.insert(*button_name, false);
}
}
shared_buttons.borrow_mut().insert(i.clone(), temp_hashmap);
shared_buttons.borrow_mut().insert(*i, temp_hashmap);
}
// State of search results

View file

@ -45,7 +45,7 @@ pub const KEY_SPACE: u32 = 65;
// pub const KEY_HOME: u32 = 115;
// pub const KEY_END: u32 = 110;
#[derive(Eq, PartialEq)]
#[derive(Eq, PartialEq, Copy, Clone)]
pub enum PopoverTypes {
All,
Size,
@ -81,6 +81,7 @@ pub enum Message {
BadExtensions(BadExtensions),
}
#[derive(Clone, Copy)]
pub enum ColumnsDuplicates {
// Columns for duplicate treeview
ActivatableSelectButton = 0,
@ -95,6 +96,7 @@ pub enum ColumnsDuplicates {
TextColor,
}
#[derive(Clone, Copy)]
pub enum ColumnsEmptyFolders {
// Columns for empty folder treeview
SelectionButton = 0,
@ -104,17 +106,20 @@ pub enum ColumnsEmptyFolders {
ModificationAsSecs,
}
#[derive(Clone, Copy)]
pub enum ColumnsIncludedDirectory {
// Columns for Included Directories in upper Notebook
Path = 0,
ReferenceButton,
}
#[derive(Clone, Copy)]
pub enum ColumnsExcludedDirectory {
// Columns for Excluded Directories in upper Notebook
Path = 0,
}
#[derive(Clone, Copy)]
pub enum ColumnsBigFiles {
SelectionButton = 0,
Size,
@ -125,6 +130,7 @@ pub enum ColumnsBigFiles {
ModificationAsSecs,
}
#[derive(Clone, Copy)]
pub enum ColumnsEmptyFiles {
SelectionButton = 0,
Name,
@ -133,6 +139,7 @@ pub enum ColumnsEmptyFiles {
ModificationAsSecs,
}
#[derive(Clone, Copy)]
pub enum ColumnsTemporaryFiles {
SelectionButton = 0,
Name,
@ -141,6 +148,7 @@ pub enum ColumnsTemporaryFiles {
ModificationAsSecs,
}
#[derive(Clone, Copy)]
pub enum ColumnsSimilarImages {
ActivatableSelectButton = 0,
SelectionButton,
@ -157,6 +165,7 @@ pub enum ColumnsSimilarImages {
TextColor,
}
#[derive(Clone, Copy)]
pub enum ColumnsSimilarVideos {
ActivatableSelectButton = 0,
SelectionButton,
@ -171,6 +180,7 @@ pub enum ColumnsSimilarVideos {
TextColor,
}
#[derive(Clone, Copy)]
pub enum ColumnsSameMusic {
ActivatableSelectButton = 0,
SelectionButton,
@ -192,6 +202,7 @@ pub enum ColumnsSameMusic {
TextColor,
}
#[derive(Clone, Copy)]
pub enum ColumnsInvalidSymlinks {
SelectionButton = 0,
Name,
@ -202,6 +213,7 @@ pub enum ColumnsInvalidSymlinks {
ModificationAsSecs,
}
#[derive(Clone, Copy)]
pub enum ColumnsBrokenFiles {
SelectionButton = 0,
Name,
@ -211,6 +223,7 @@ pub enum ColumnsBrokenFiles {
ModificationAsSecs,
}
#[derive(Clone, Copy)]
pub enum ColumnsBadExtensions {
SelectionButton = 0,
Name,

View file

@ -2,7 +2,7 @@ pub const NUMBER_OF_NOTEBOOK_MAIN_TABS: usize = 11;
// pub const NUMBER_OF_NOTEBOOK_UPPER_TABS: usize = 3;
// Needs to be updated when changed order of notebook tabs
#[derive(Eq, PartialEq, Hash, Clone, Debug)]
#[derive(Eq, PartialEq, Hash, Clone, Debug, Copy)]
pub enum NotebookMainEnum {
Duplicate = 0,
EmptyDirectories,
@ -50,7 +50,7 @@ pub fn get_all_main_tabs() -> [NotebookMainEnum; NUMBER_OF_NOTEBOOK_MAIN_TABS] {
]
}
#[derive(Eq, PartialEq, Hash, Clone, Debug)]
#[derive(Eq, PartialEq, Hash, Clone, Debug, Copy)]
pub enum NotebookUpperEnum {
IncludedDirectories = 0,
ExcludedDirectories,

View file

@ -157,7 +157,7 @@ impl LoadSaveStruct {
if self.loaded_items.contains_key(&key) {
let item = self.loaded_items.get(&key).unwrap().clone().into_iter().filter(|e| !e.is_empty()).collect::<Vec<String>>();
return if item.len() == 1 {
let text = item[0].clone().trim().to_lowercase();
let text = item[0].trim().to_lowercase();
if text == "false" || text == "0" {
false
} else if text == "true" || text == "1" {
@ -214,7 +214,6 @@ impl LoadSaveStruct {
self.loaded_items.insert(key, vec_string);
}
//noinspection RsLift
pub fn open_save_file(&self, text_view_errors: &TextView, save_configuration: bool, manual_execution: bool) -> Option<(File, PathBuf)> {
if let Some(proj_dirs) = ProjectDirs::from("pl", "Qarmin", "Czkawka") {
// Lin: /home/username/.config/czkawka