Skip to content

Commit

Permalink
More work on Krokiet (#1210)
Browse files Browse the repository at this point in the history
* Disable flaky tests

* More

* More

* About

* TODO

* More

* Heh

* Progress

* A little

* Music

* Models

* Subsettings

* Water

* Header

* Saving

* Poprawa elementów

* Ad

* Names
  • Loading branch information
qarmin authored Feb 17, 2024
1 parent 9599ed5 commit 0446ff3
Show file tree
Hide file tree
Showing 37 changed files with 1,930 additions and 392 deletions.
14 changes: 13 additions & 1 deletion czkawka_core/src/bad_extensions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::{BTreeSet, HashMap};
use std::io::prelude::*;
use std::mem;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;

Expand Down Expand Up @@ -169,6 +169,18 @@ pub struct BadFileEntry {
pub proper_extensions: String,
}

impl ResultEntry for BadFileEntry {
fn get_path(&self) -> &Path {
&self.path
}
fn get_modified_date(&self) -> u64 {
self.modified_date
}
fn get_size(&self) -> u64 {
self.size
}
}

#[derive(Default)]
pub struct Info {
pub number_of_files_with_bad_extension: usize,
Expand Down
12 changes: 11 additions & 1 deletion czkawka_core/src/common_dir_traversal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::BTreeMap;
use std::fmt::Display;
use std::fs;
use std::fs::{DirEntry, FileType, Metadata};
#[cfg(target_family = "unix")]
Expand Down Expand Up @@ -87,6 +88,15 @@ pub enum ErrorType {
NonExistentFile,
}

impl Display for ErrorType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ErrorType::InfiniteRecursion => write!(f, "Infinite recursion"),
ErrorType::NonExistentFile => write!(f, "Non existent file"),
}
}
}

#[derive(Copy, Clone, Eq, PartialEq)]
pub enum Collect {
InvalidSymlinks,
Expand Down Expand Up @@ -318,7 +328,7 @@ where
{
#[fun_time(message = "run(collecting files/dirs)", level = "debug")]
pub fn run(self) -> DirTraversalResult<T> {
assert!(self.tool_type != ToolType::None, "Tool type cannot be None");
assert_ne!(self.tool_type, ToolType::None, "Tool type cannot be None");

let mut all_warnings = vec![];
let mut grouped_file_entries: BTreeMap<T, Vec<FileEntry>> = BTreeMap::new();
Expand Down
19 changes: 14 additions & 5 deletions czkawka_core/src/temporary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@ const TEMP_EXTENSIONS: &[&str] = &[
];

#[derive(Clone, Serialize, Debug)]
pub struct FileEntry {
pub struct TemporaryFileEntry {
pub path: PathBuf,
pub modified_date: u64,
}

impl TemporaryFileEntry {
pub fn get_path(&self) -> &PathBuf {
&self.path
}
pub fn get_modified_date(&self) -> u64 {
self.modified_date
}
}

#[derive(Default)]
pub struct Info {
pub number_of_temporary_files: usize,
Expand All @@ -45,7 +54,7 @@ pub struct Info {
pub struct Temporary {
common_data: CommonToolData,
information: Info,
temporary_files: Vec<FileEntry>,
temporary_files: Vec<TemporaryFileEntry>,
}

impl Temporary {
Expand Down Expand Up @@ -138,7 +147,7 @@ impl Temporary {

true
}
pub fn get_file_entry(&self, atomic_counter: &Arc<AtomicUsize>, entry_data: &DirEntry, warnings: &mut Vec<String>) -> Option<FileEntry> {
pub fn get_file_entry(&self, atomic_counter: &Arc<AtomicUsize>, entry_data: &DirEntry, warnings: &mut Vec<String>) -> Option<TemporaryFileEntry> {
atomic_counter.fetch_add(1, Ordering::Relaxed);

let current_file_name = entry_data.path();
Expand All @@ -158,7 +167,7 @@ impl Temporary {
};

// Creating new file entry
Some(FileEntry {
Some(TemporaryFileEntry {
modified_date: get_modified_time(&metadata, warnings, &current_file_name, false),
path: current_file_name,
})
Expand Down Expand Up @@ -234,7 +243,7 @@ impl CommonData for Temporary {
}

impl Temporary {
pub const fn get_temporary_files(&self) -> &Vec<FileEntry> {
pub const fn get_temporary_files(&self) -> &Vec<TemporaryFileEntry> {
&self.temporary_files
}

Expand Down
4 changes: 2 additions & 2 deletions czkawka_gui/src/compute_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ fn compute_duplicate_finder(
fn vector_sort_unstable_entry_by_path<T>(vector: &[T]) -> Vec<T>
where
T: ResultEntry + Clone,
T: std::marker::Send,
T: Send,
{
if vector.len() >= 2 {
let mut vector = vector.to_vec();
Expand All @@ -1296,7 +1296,7 @@ where
fn vector_sort_simple_unstable_entry_by_path<T>(vector: &[T]) -> Vec<T>
where
T: ResultEntry + Clone,
T: std::marker::Send,
T: Send,
{
let mut vector = vector.to_vec();
vector.par_sort_unstable_by(|a, b| split_path_compare(a.get_path(), b.get_path()));
Expand Down
6 changes: 3 additions & 3 deletions czkawka_gui/src/connect_things/connect_button_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ pub fn connect_button_search(gui_data: &GuiData, result_sender: Sender<Message>,
entry_info.set_text(&flg!("searching_for_data"));

// Resets progress bars
progress_bar_all_stages.set_fraction(0 as f64);
progress_bar_current_stage.set_fraction(0 as f64);
progress_bar_all_stages.set_fraction(0f64);
progress_bar_current_stage.set_fraction(0f64);

reset_text_view(&text_view_errors);

Expand Down Expand Up @@ -162,7 +162,7 @@ impl LoadedCommonItems {
.as_str()
.to_string()
.split(',')
.map(std::string::ToString::to_string)
.map(ToString::to_string)
.collect::<Vec<String>>();
let allowed_extensions = entry_allowed_extensions.text().as_str().to_string();
let excluded_extensions = entry_excluded_extensions.text().as_str().to_string();
Expand Down
4 changes: 2 additions & 2 deletions czkawka_gui/src/connect_things/connect_progress_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ fn progress_default(gui_data: &GuiData, item: &ProgressData) {

fn common_set_data(item: &ProgressData, progress_bar_all_stages: &ProgressBar, progress_bar_current_stage: &ProgressBar, taskbar_state: &Rc<RefCell<TaskbarProgress>>) {
if item.entries_to_check != 0 {
let all_stages = (item.current_stage as f64 + (item.entries_checked) as f64 / item.entries_to_check as f64) / (item.max_stage + 1) as f64;
let all_stages = (item.current_stage as f64 + item.entries_checked as f64 / item.entries_to_check as f64) / (item.max_stage + 1) as f64;
let all_stages = if all_stages > 0.99 { 0.99 } else { all_stages };
progress_bar_all_stages.set_fraction(all_stages);
progress_bar_current_stage.set_fraction((item.entries_checked) as f64 / item.entries_to_check as f64);
progress_bar_current_stage.set_fraction(item.entries_checked as f64 / item.entries_to_check as f64);
taskbar_state.borrow().set_progress_value(
((item.current_stage as usize) * item.entries_to_check + item.entries_checked) as u64,
item.entries_to_check as u64 * (item.max_stage + 1) as u64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn add_manually_directories(window_main: &Window, tree_view: &TreeView, excluded
let list_store = get_list_store(&tree_view);

if excluded_items {
if !(check_if_value_is_in_list_store(&list_store, ColumnsExcludedDirectory::Path as i32, &text)) {
if !check_if_value_is_in_list_store(&list_store, ColumnsExcludedDirectory::Path as i32, &text) {
let values: [(u32, &dyn ToValue); 1] = [(ColumnsExcludedDirectory::Path as u32, &text)];
list_store.set(&list_store.append(), &values);
}
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/ui/about_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ This program is free to use and will always be.
<property name="license-type">mit-x11</property>
<property name="logo-icon-name">help-about-symbolic</property>
<property name="program-name">Czkawka</property>
<property name="version">6.1.0</property>
<property name="version">7.0.0</property>
</object>
</interface>
2 changes: 1 addition & 1 deletion czkawka_gui/ui/czkawka.cmb
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@
(5,177,"GtkWidget","focusable","1",None,None,None,None,None,None,None,None,None),
(5,177,"GtkWidget","hexpand","1",None,None,None,None,None,None,None,None,None),
(5,178,"GtkEditable","editable","0",None,None,None,None,None,None,None,None,None),
(5,178,"GtkEditable","text","Czkawka 6.1.0",1,None,None,None,None,None,None,None,None),
(5,178,"GtkEditable","text","Czkawka 7.0.0",1,None,None,None,None,None,None,None,None),
(5,178,"GtkEditable","xalign","1",None,None,None,None,None,None,None,None,None),
(5,178,"GtkEntry","has-frame","0",None,None,None,None,None,None,None,None,None),
(5,178,"GtkWidget","focusable","1",None,None,None,None,None,None,None,None,None),
Expand Down
2 changes: 1 addition & 1 deletion czkawka_gui/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@
<property name="editable">0</property>
<property name="focusable">1</property>
<property name="has-frame">0</property>
<property name="text" translatable="yes">Czkawka 6.1.0</property>
<property name="text" translatable="yes">Czkawka 7.0.0</property>
<property name="xalign">1</property>
</object>
</child>
Expand Down
6 changes: 5 additions & 1 deletion krokiet/icons/settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions krokiet/icons/subsettings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0446ff3

Please sign in to comment.