Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference folder #516

Merged
merged 9 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- Option to not remove cache from non existent files(e.g. from unplugged pendrive) - [#472](https://github.com/qarmin/czkawka/pull/472)
- Add multiple tooltips with helpful messages - [#472](https://github.com/qarmin/czkawka/pull/472)
- Allow to cache prehash - [#477](https://github.com/qarmin/czkawka/pull/477)
- Improve custom selecting of records(allows to use Rust red regex) - [#489](https://github.com/qarmin/czkawka/pull/478)
- Improve custom selecting of records(allows to use Rust regex) - [#489](https://github.com/qarmin/czkawka/pull/478)
- Remove support for finding zeroed files - [#461](https://github.com/qarmin/czkawka/pull/461)
- Remove HashMB mode - [#476](https://github.com/qarmin/czkawka/pull/476)
- Approximate comparison of music - [#483](https://github.com/qarmin/czkawka/pull/483)
Expand Down
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- CLI frontend - for easy automation
- GUI frontend - uses modern GTK 3 and looks similar to FSlint
- No spying - Czkawka does not have access to the Internet, nor does it collect any user information or statistics
- Multilingual - app support multiple languages
- Multilingual - support multiple languages like Polish, English or Italian
- Multiple tools to use:
- Duplicates - Finds duplicates based on file name, size or hash
- Empty Folders - Finds empty folders with the help of an advanced algorithm
Expand Down Expand Up @@ -50,12 +50,12 @@ I set the minimal file size to check to 1KB on all programs.

| App | Executing Time |
|:---------------------------:|:--------------:|
| FSlint 2.4.7 (First Run) | 86s |
| FSlint 2.4.7 (Second Run) | 43s |
| Czkawka 3.0.0 (First Run) | 8s |
| Czkawka 3.0.0 (Second Run) | 7s |
| DupeGuru 4.1.1 (First Run) | 22s |
| DupeGuru 4.1.1 (Second Run) | 21s |
| FSlint 2.4.7 (First Run) | 86s |
| FSlint 2.4.7 (Second Run) | 43s |
| Czkawka 3.0.0 (First Run) | 8s |
| Czkawka 3.0.0 (Second Run) | 7s |
| DupeGuru 4.1.1 (First Run) | 22s |
| DupeGuru 4.1.1 (Second Run) | 21s |

I used Mprof for checking memory usage of FSlint and DupeGuru, and Heaptrack for Czkawka.

Expand Down Expand Up @@ -91,31 +91,31 @@ Similar images which check 349 image files that occupied 1.7 GB

Bleachbit is a master at finding and removing temporary files, while Czkawka only finds the most basic ones. So these two apps shouldn't be compared directly or be considered as an alternative to one another.

| | Czkawka | FSlint | DupeGuru | Bleachbit |
| | Czkawka | FSlint | DupeGuru | Bleachbit |
|:----------------------:|:-----------:|:----------:|:-----------------:|:-----------:|
| Language | Rust | Python | Python/Obj-C | Python |
| OS | Lin,Mac,Win | Lin | Lin,Mac,Win | Lin,Mac,Win |
| Framework | GTK 3 | PyGTK2 | Qt 5 (PyQt)/Cocoa | PyGTK3 |
| Duplicate finder | • | | | |
| Empty files | • | | | |
| Empty folders | • | | | |
| Temporary files | • | | | |
| Big files | • | | | |
| Similar images | • | | | |
| Similar videos | • | | | |
| Music duplicates(tags) | • | | | |
| Invalid symlinks | • | | | |
| Broken files | • | | | |
| Names conflict | • | | | |
| Installed packages | | | | |
| Invalid names | | | | |
| Bad ID | | | | |
| Non stripped binaries | | | | |
| Redundant whitespace | | | | |
| Overwriting files | | | | |
| Multiple languages(po) | • | • | | • |
| Cache support | • | | | |
| In active development | Yes | No | Yes | Yes |
| Language | Rust | Python | Python/Obj-C | Python |
| OS | Lin,Mac,Win | Lin | Lin,Mac,Win | Lin,Mac,Win |
| Framework | GTK 3 | PyGTK2 | Qt 5 (PyQt)/Cocoa | PyGTK3 |
| Duplicate finder | • | | | |
| Empty files | • | | | |
| Empty folders | • | | | |
| Temporary files | • | | | |
| Big files | • | | | |
| Similar images | • | | | |
| Similar videos | • | | | |
| Music duplicates(tags) | • | | | |
| Invalid symlinks | • | | | |
| Broken files | • | | | |
| Names conflict | • | | | |
| Installed packages | | | | |
| Invalid names | | | | |
| Bad ID | | | | |
| Non stripped binaries | | | | |
| Redundant whitespace | | | | |
| Overwriting files | | | | |
| Multiple languages | | | | • |
| Cache support | • | | | |
| In active development | Yes | No | Yes | Yes |

## Other apps
There are many similar applications to Czkawka on the Internet, which do some things better and some things worse.
Expand Down
7 changes: 0 additions & 7 deletions czkawka_core/src/big_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub enum DeleteMethod {
/// Info struck with helpful information's about results
#[derive(Default)]
pub struct Info {
pub taken_space: u64,
pub number_of_real_files: usize,
}

Expand Down Expand Up @@ -302,7 +301,6 @@ impl BigFile {
if self.information.number_of_real_files < self.number_of_files_to_check {
new_map.entry(*size).or_insert_with(Vec::new);
new_map.get_mut(size).unwrap().push(file.clone());
self.information.taken_space += size;
self.information.number_of_real_files += 1;
} else {
break;
Expand Down Expand Up @@ -445,11 +443,6 @@ impl SaveResults for BigFile {
impl PrintResults for BigFile {
fn print_results(&self) {
let start_time: SystemTime = SystemTime::now();
println!(
"Found {} files which take {}:",
self.information.number_of_real_files,
self.information.taken_space.file_size(options::BINARY).unwrap()
);
for (size, vector) in self.big_files.iter().rev() {
// TODO Align all to same width
for entry in vector {
Expand Down
4 changes: 0 additions & 4 deletions czkawka_core/src/broken_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ pub enum TypeOfFile {
#[derive(Default)]
pub struct Info {
pub number_of_broken_files: usize,
pub number_of_removed_files: usize,
pub number_of_failed_to_remove_files: usize,
}

impl Info {
Expand Down Expand Up @@ -550,8 +548,6 @@ impl DebugPrint for BrokenFiles {
println!("Errors size - {}", self.text_messages.errors.len());
println!("Warnings size - {}", self.text_messages.warnings.len());
println!("Messages size - {}", self.text_messages.messages.len());
println!("Number of removed files - {}", self.information.number_of_removed_files);
println!("Number of failed to remove files - {}", self.information.number_of_failed_to_remove_files);

println!("### Other");

Expand Down
22 changes: 22 additions & 0 deletions czkawka_core/src/common_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ use crate::common_messages::Messages;
pub struct Directories {
pub excluded_directories: Vec<PathBuf>,
pub included_directories: Vec<PathBuf>,
pub reference_directories: Vec<PathBuf>,
}

impl Directories {
pub fn new() -> Self {
Default::default()
}

pub fn set_reference_directory(&mut self, reference_directory: Vec<PathBuf>) {
self.reference_directories = reference_directory
}

/// Setting included directories, at least one must be provided
pub fn set_included_directory(&mut self, included_directory: Vec<PathBuf>, text_messages: &mut Messages) -> bool {
let start_time: SystemTime = SystemTime::now();
Expand Down Expand Up @@ -146,15 +151,18 @@ impl Directories {
if cfg!(target_family = "windows") {
self.included_directories = self.included_directories.iter().map(Common::normalize_windows_path).collect();
self.excluded_directories = self.excluded_directories.iter().map(Common::normalize_windows_path).collect();
self.reference_directories = self.reference_directories.iter().map(Common::normalize_windows_path).collect();
}

// Remove duplicated entries like: "/", "/"

self.excluded_directories.sort();
self.included_directories.sort();
self.reference_directories.sort();

self.excluded_directories.dedup();
self.included_directories.dedup();
self.reference_directories.dedup();

// Optimize for duplicated included directories - "/", "/home". "/home/Pulpit" to "/"
if recursive_search {
Expand Down Expand Up @@ -251,6 +259,20 @@ impl Directories {

self.excluded_directories = optimized_excluded;

// Selecting Reference folders
{
let mut ref_folders = Vec::new();
for folder in &self.reference_directories {
if self.included_directories.iter().any(|e| folder.starts_with(&e)) {
ref_folders.push(folder.clone());
// println!("REF: VALID reference folder {:?}", folder);
} else {
// println!("REF: Invalid reference folder {:?}", folder);
}
}
self.reference_directories = ref_folders;
}

if self.included_directories.is_empty() {
text_messages
.errors
Expand Down
9 changes: 6 additions & 3 deletions czkawka_core/src/common_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ impl Messages {
if !self.messages.is_empty() {
text_to_return += "-------------------------------MESSAGES--------------------------------\n";
for i in &self.messages {
text_to_return += format!("{}\n", i).as_str();
text_to_return += i;
text_to_return += "\n";
}
text_to_return += "---------------------------END OF MESSAGES-----------------------------\n";
}
Expand All @@ -27,7 +28,8 @@ impl Messages {
text_to_return += "-------------------------------WARNINGS--------------------------------\n";

for i in &self.warnings {
text_to_return += format!("{}\n", i).as_str();
text_to_return += i;
text_to_return += "\n";
}
text_to_return += "---------------------------END OF WARNINGS-----------------------------\n";
}
Expand All @@ -36,7 +38,8 @@ impl Messages {
text_to_return += "--------------------------------ERRORS---------------------------------\n";

for i in &self.errors {
text_to_return += format!("{}\n", i).as_str();
text_to_return += i;
text_to_return += "\n";
}
text_to_return += "----------------------------END OF ERRORS------------------------------\n";
}
Expand Down
Loading