Basic changes
This commit is contained in:
parent
f9fa7d3879
commit
1095d719d0
|
@ -6,6 +6,6 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
humansize = "1.1.0"
|
||||
#rayon = "1.4.0"
|
||||
blake3 = "0.3.6"
|
||||
#rayon = "1.4.0"
|
||||
#regex = "1.3.9"
|
12
README.md
12
README.md
|
@ -5,20 +5,20 @@ It is in very early development, so most of the functions aren't added and doesn
|
|||
|
||||
## Done
|
||||
- Basic menu(need refactoring)
|
||||
- Duplicated file finding
|
||||
- Duplicated file finding - CLI
|
||||
- Including and excluding directories(absolute pathes)
|
||||
- Option to remove file
|
||||
- Option to remove files in different ways
|
||||
- Fast(by size) or accurate(by hash) file checking
|
||||
-
|
||||
|
||||
## TODO
|
||||
- Duplicated file finding
|
||||
- saving to file
|
||||
- Duplicated file finding - CLI
|
||||
- saving results to file
|
||||
- support for * when excluding files and folders
|
||||
- Graphical UI(GTK)
|
||||
- GUI(GTK)
|
||||
- Removing empty folders
|
||||
- Files with debug symbols
|
||||
- Support for showing only duplicates with specific extension, name(Regex support needed)
|
||||
- Maybe windows support, but this will need some refactoring in code
|
||||
|
||||
## License
|
||||
Czkawka is released under the terms of the GNU Lesser General Public License, version 2.1 or, at your option, any later version, as published by the Free Software Foundation.
|
|
@ -7,13 +7,22 @@ use std::path::Path;
|
|||
use std::time::SystemTime;
|
||||
use std::{fs, process};
|
||||
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum CheckingMethod {
|
||||
SIZE,
|
||||
HASH,
|
||||
}
|
||||
|
||||
// TODO
|
||||
#[allow(dead_code)]
|
||||
pub enum TypeOfDelete {
|
||||
AllExceptRandom, // Choose one random file from duplicates which won't be deleted
|
||||
AllExceptNewest,
|
||||
AllExceptOldest,
|
||||
OneOldest,
|
||||
OneNewest,
|
||||
OneRandom
|
||||
}
|
||||
|
||||
pub struct DuplicateFinder {
|
||||
number_of_checked_files: usize,
|
||||
|
@ -96,7 +105,6 @@ impl DuplicateFinder {
|
|||
}
|
||||
}
|
||||
|
||||
println!("{:?}", &self.allowed_extensions);
|
||||
if self.allowed_extensions.is_empty() {
|
||||
println!("No valid extensions were provided, so allowing all extensions by default.");
|
||||
}
|
||||
|
@ -197,7 +205,6 @@ impl DuplicateFinder {
|
|||
checked_directories.push(directory.trim().to_string());
|
||||
}
|
||||
}
|
||||
println!("{:?}", checked_directories);
|
||||
self.excluded_directories = checked_directories;
|
||||
|
||||
//DuplicateFinder::print_time(start_time, SystemTime::now(), "set_exclude_directory".to_string());
|
||||
|
@ -429,7 +436,6 @@ impl DuplicateFinder {
|
|||
// println!("-----------------------------------------");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn print_duplicated_entries(&self, check_method: &CheckingMethod) {
|
||||
let start_time: SystemTime = SystemTime::now();
|
||||
let mut number_of_files: u64 = 0;
|
||||
|
@ -471,13 +477,13 @@ impl DuplicateFinder {
|
|||
number_of_groups,
|
||||
self.lost_space.file_size(options::BINARY).unwrap()
|
||||
);
|
||||
// for i in &self.files_with_identical_size {
|
||||
// println!("Size - {}", i.0);
|
||||
// for j in i.1 {
|
||||
// println!("{}", j.path);
|
||||
// }
|
||||
// println!();
|
||||
// }
|
||||
for i in &self.files_with_identical_size {
|
||||
println!("Size - {}", i.0);
|
||||
for j in i.1 {
|
||||
println!("{}", j.path);
|
||||
}
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
DuplicateFinder::print_time(start_time, SystemTime::now(), "print_duplicated_entries".to_string());
|
||||
|
|
26
src/main.rs
26
src/main.rs
|
@ -39,13 +39,11 @@ fn main() {
|
|||
println!("FATAL ERROR: Missing argument for {}", all_arguments[argument]);
|
||||
process::exit(1);
|
||||
}
|
||||
} else if !can_pass_argument {
|
||||
println!("FATAL ERROR: Argument \"{}\" is not linked to any command", all_arguments[argument]);
|
||||
process::exit(1);
|
||||
} else {
|
||||
if !can_pass_argument {
|
||||
println!("FATAL ERROR: Argument \"{}\" is not linked to any command", all_arguments[argument]);
|
||||
process::exit(1);
|
||||
} else {
|
||||
can_pass_argument = false;
|
||||
}
|
||||
can_pass_argument = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +58,7 @@ fn main() {
|
|||
match commands_arguments[0].as_ref() {
|
||||
"--d" => {
|
||||
let mut df = duplicate::DuplicateFinder::new();
|
||||
let mut check_method: duplicate::CheckingMethod = duplicate::CheckingMethod::HASH;
|
||||
|
||||
if ArgumentsPair::has_command(&arguments, "-i") {
|
||||
df.set_include_directory(ArgumentsPair::get_argument(&arguments, "-i"));
|
||||
|
@ -89,7 +88,6 @@ fn main() {
|
|||
df.set_excluded_items(ArgumentsPair::get_argument(&arguments, "-k"));
|
||||
}
|
||||
if ArgumentsPair::has_command(&arguments, "-l") {
|
||||
let check_method: duplicate::CheckingMethod;
|
||||
if ArgumentsPair::get_argument(&arguments, "-l").to_lowercase() == "size" {
|
||||
check_method = duplicate::CheckingMethod::SIZE;
|
||||
} else if ArgumentsPair::get_argument(&arguments, "-l").to_lowercase() == "hash" {
|
||||
|
@ -98,8 +96,8 @@ fn main() {
|
|||
println!("-l can only have values hash or size");
|
||||
process::exit(1);
|
||||
}
|
||||
df.find_duplicates(check_method, ArgumentsPair::has_command(&arguments, "--delete"));
|
||||
}
|
||||
df.find_duplicates(check_method, ArgumentsPair::has_command(&arguments, "--delete"));
|
||||
}
|
||||
"--h" | "--help" => {
|
||||
print_help();
|
||||
|
@ -120,18 +118,22 @@ fn print_help() {
|
|||
println!(" Usage example:");
|
||||
println!(" czkawka --help");
|
||||
println!(" czkawka");
|
||||
println!(" --d - <-i directory_to_search> [-e exclude_directories = \"\"] [-s min_size = 1024] [-x allowed_extension = \"\"] [-l type_of_search = \"hash\"] [--delete] - search for duplicates files");
|
||||
println!();
|
||||
println!(
|
||||
" --d - <-i directory_to_search> [-e exclude_directories = \"\"] [-s min_size = 1024] [-x allowed_extension = \"\"] [-l type_of_search = \"hash\"] [--delete] - search for duplicates files"
|
||||
);
|
||||
println!(" -i directory_to_search - list of directories which should will be searched like /home/rafal");
|
||||
println!(" -e exclude_directories - list of directories which will be excluded from search.");
|
||||
println!(" -s min_size - minimum size of checked files in bytes, assigning bigger value may speed up searching.");
|
||||
println!(" -x allowed_extension - list of checked extension, e.g. \"jpg,mp4\" will allow to check \"book.jpg\" and \"car.mp4\" but not roman.png.There are also helpful macros which allow to easy use a typcal extension like IMAGE(\"jpg,kra,gif,png,bmp,tiff,webp,hdr,svg\") or TEXT(\"txt,doc,docx,odt,rtf\")");
|
||||
println!(" -k type_of_search - allows to use fastest which takes into account only size, and more accurate which check if file contnet is same(hashes).");
|
||||
println!(" --delete - removing file except one.");
|
||||
println!(" -delete - removing file except one.");
|
||||
println!(" Usage example:");
|
||||
println!(" czkawka --d -i \"/home/rafal/,/home/szczekacz\" -e \"/home/rafal/Pulpit,/home/rafal/Obrazy\" -s 25 -x \"7z,rar,IMAGE\" -k \"size\" --delete");
|
||||
println!(" czkawka --d -i \"/home/rafal/,/home/szczekacz\" -e \"/home/rafal/Pulpit,/home/rafal/Obrazy\" -s 25 -x \"7z,rar,IMAGE\" -k \"size\" -delete");
|
||||
println!(" czkawka --d -i \"/etc/,/mnt/Miecz\" -s 1000 -x \"VIDEO\" -k \"hash\"");
|
||||
println!(" czkawka --d -i \"/etc/\" --delete");
|
||||
println!(" --e");
|
||||
println!();
|
||||
println!(" --e - option to find and delete empty folders");
|
||||
println!();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue