Basic changes
This commit is contained in:
parent
f9fa7d3879
commit
1095d719d0
|
@ -6,6 +6,6 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
humansize = "1.1.0"
|
humansize = "1.1.0"
|
||||||
#rayon = "1.4.0"
|
|
||||||
blake3 = "0.3.6"
|
blake3 = "0.3.6"
|
||||||
|
#rayon = "1.4.0"
|
||||||
#regex = "1.3.9"
|
#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
|
## Done
|
||||||
- Basic menu(need refactoring)
|
- Basic menu(need refactoring)
|
||||||
- Duplicated file finding
|
- Duplicated file finding - CLI
|
||||||
- Including and excluding directories(absolute pathes)
|
- 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
|
- Fast(by size) or accurate(by hash) file checking
|
||||||
-
|
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- Duplicated file finding
|
- Duplicated file finding - CLI
|
||||||
- saving to file
|
- saving results to file
|
||||||
- support for * when excluding files and folders
|
- support for * when excluding files and folders
|
||||||
- Graphical UI(GTK)
|
- GUI(GTK)
|
||||||
- Removing empty folders
|
- Removing empty folders
|
||||||
- Files with debug symbols
|
- Files with debug symbols
|
||||||
- Support for showing only duplicates with specific extension, name(Regex support needed)
|
- Support for showing only duplicates with specific extension, name(Regex support needed)
|
||||||
|
- Maybe windows support, but this will need some refactoring in code
|
||||||
|
|
||||||
## License
|
## 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.
|
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::time::SystemTime;
|
||||||
use std::{fs, process};
|
use std::{fs, process};
|
||||||
|
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum CheckingMethod {
|
pub enum CheckingMethod {
|
||||||
SIZE,
|
SIZE,
|
||||||
HASH,
|
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 {
|
pub struct DuplicateFinder {
|
||||||
number_of_checked_files: usize,
|
number_of_checked_files: usize,
|
||||||
|
@ -96,7 +105,6 @@ impl DuplicateFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:?}", &self.allowed_extensions);
|
|
||||||
if self.allowed_extensions.is_empty() {
|
if self.allowed_extensions.is_empty() {
|
||||||
println!("No valid extensions were provided, so allowing all extensions by default.");
|
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());
|
checked_directories.push(directory.trim().to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("{:?}", checked_directories);
|
|
||||||
self.excluded_directories = checked_directories;
|
self.excluded_directories = checked_directories;
|
||||||
|
|
||||||
//DuplicateFinder::print_time(start_time, SystemTime::now(), "set_exclude_directory".to_string());
|
//DuplicateFinder::print_time(start_time, SystemTime::now(), "set_exclude_directory".to_string());
|
||||||
|
@ -429,7 +436,6 @@ impl DuplicateFinder {
|
||||||
// println!("-----------------------------------------");
|
// println!("-----------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn print_duplicated_entries(&self, check_method: &CheckingMethod) {
|
fn print_duplicated_entries(&self, check_method: &CheckingMethod) {
|
||||||
let start_time: SystemTime = SystemTime::now();
|
let start_time: SystemTime = SystemTime::now();
|
||||||
let mut number_of_files: u64 = 0;
|
let mut number_of_files: u64 = 0;
|
||||||
|
@ -471,13 +477,13 @@ impl DuplicateFinder {
|
||||||
number_of_groups,
|
number_of_groups,
|
||||||
self.lost_space.file_size(options::BINARY).unwrap()
|
self.lost_space.file_size(options::BINARY).unwrap()
|
||||||
);
|
);
|
||||||
// for i in &self.files_with_identical_size {
|
for i in &self.files_with_identical_size {
|
||||||
// println!("Size - {}", i.0);
|
println!("Size - {}", i.0);
|
||||||
// for j in i.1 {
|
for j in i.1 {
|
||||||
// println!("{}", j.path);
|
println!("{}", j.path);
|
||||||
// }
|
}
|
||||||
// println!();
|
println!();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DuplicateFinder::print_time(start_time, SystemTime::now(), "print_duplicated_entries".to_string());
|
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]);
|
println!("FATAL ERROR: Missing argument for {}", all_arguments[argument]);
|
||||||
process::exit(1);
|
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 {
|
} else {
|
||||||
if !can_pass_argument {
|
can_pass_argument = false;
|
||||||
println!("FATAL ERROR: Argument \"{}\" is not linked to any command", all_arguments[argument]);
|
|
||||||
process::exit(1);
|
|
||||||
} else {
|
|
||||||
can_pass_argument = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +58,7 @@ fn main() {
|
||||||
match commands_arguments[0].as_ref() {
|
match commands_arguments[0].as_ref() {
|
||||||
"--d" => {
|
"--d" => {
|
||||||
let mut df = duplicate::DuplicateFinder::new();
|
let mut df = duplicate::DuplicateFinder::new();
|
||||||
|
let mut check_method: duplicate::CheckingMethod = duplicate::CheckingMethod::HASH;
|
||||||
|
|
||||||
if ArgumentsPair::has_command(&arguments, "-i") {
|
if ArgumentsPair::has_command(&arguments, "-i") {
|
||||||
df.set_include_directory(ArgumentsPair::get_argument(&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"));
|
df.set_excluded_items(ArgumentsPair::get_argument(&arguments, "-k"));
|
||||||
}
|
}
|
||||||
if ArgumentsPair::has_command(&arguments, "-l") {
|
if ArgumentsPair::has_command(&arguments, "-l") {
|
||||||
let check_method: duplicate::CheckingMethod;
|
|
||||||
if ArgumentsPair::get_argument(&arguments, "-l").to_lowercase() == "size" {
|
if ArgumentsPair::get_argument(&arguments, "-l").to_lowercase() == "size" {
|
||||||
check_method = duplicate::CheckingMethod::SIZE;
|
check_method = duplicate::CheckingMethod::SIZE;
|
||||||
} else if ArgumentsPair::get_argument(&arguments, "-l").to_lowercase() == "hash" {
|
} 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");
|
println!("-l can only have values hash or size");
|
||||||
process::exit(1);
|
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" => {
|
"--h" | "--help" => {
|
||||||
print_help();
|
print_help();
|
||||||
|
@ -120,18 +118,22 @@ fn print_help() {
|
||||||
println!(" Usage example:");
|
println!(" Usage example:");
|
||||||
println!(" czkawka --help");
|
println!(" czkawka --help");
|
||||||
println!(" czkawka");
|
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!(" -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!(" -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!(" -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!(" -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!(" -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!(" 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/,/mnt/Miecz\" -s 1000 -x \"VIDEO\" -k \"hash\"");
|
||||||
println!(" czkawka --d -i \"/etc/\" --delete");
|
println!(" czkawka --d -i \"/etc/\" --delete");
|
||||||
println!(" --e");
|
println!();
|
||||||
|
println!(" --e - option to find and delete empty folders");
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue