1
0
Fork 0
mirror of synced 2024-05-02 19:44:09 +12:00
This commit is contained in:
Rafał Mikrut 2022-05-30 22:02:39 +02:00 committed by GitHub
parent 3748411ebd
commit 5119a377c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 107 additions and 75 deletions

View file

@ -8,6 +8,8 @@
- Improve checking for invalid extensions - [#705](https://github.com/qarmin/czkawka/pull/705)
- Support for finding invalid PDF files - [#705](https://github.com/qarmin/czkawka/pull/705)
- Re-enable checking for broken music files(`libasound.so.2` no longer needed) - [#705](https://github.com/qarmin/czkawka/pull/705)
- Fix disabled ui when using invalid settings in similar music - [#740](https://github.com/qarmin/czkawka/pull/740)
- Speedup searching for invalid extensions - [#740](https://github.com/qarmin/czkawka/pull/740)
## Version 4.1.0 - 24.04.2022r
- New mode - finding files whose content not match with their extension - [#678](https://github.com/qarmin/czkawka/pull/678)

View file

@ -1,4 +1,4 @@
use std::collections::BTreeSet;
use std::collections::{BTreeSet, HashMap};
use std::fs::File;
use std::io::prelude::*;
use std::io::BufWriter;
@ -27,6 +27,7 @@ static DISABLED_EXTENSIONS: &[&str] = &["file", "cache", "bak"]; // Such files c
// ("real_content_extension", "current_file_extension")
static WORKAROUNDS: &[(&str, &str)] = &[
// Wine/Windows
("der", "cat"),
("exe", "acm"),
("exe", "ax"),
("exe", "bck"),
@ -38,78 +39,86 @@ static WORKAROUNDS: &[(&str, &str)] = &[
("exe", "drv"),
("exe", "drv16"),
("exe", "ds"),
("exe", "efi"),
("exe", "exe16"),
("exe", "fon"), // Type of font or something else
("exe", "mod16"),
("exe", "msstyles"),
("exe", "mui"),
("exe", "orig"),
("exe", "signed"),
("exe", "sys"),
("exe", "sys"),
("exe", "tlb"),
("exe", "vxd"),
("exe", "sys"),
("exe", "mod16"),
("exe", "winmd"),
("xml", "adml"),
("xml", "manifest"),
("xml", "mum"),
// Other
("zip", "odg"), // Libreoffice
("gz", "blend"), // Blender
("gz", "crate"), // Cargo
("gz", "svgz"), // Archive svg
("gz", "tgz"), // Archive
("html", "md"), // Markdown
("jpg", "jfif"), // Photo format
("mobi", "azw3"), // Ebook format
("mpg", "vob"), // Weddings in parts have usually vob extension
("obj", "bin"), // Multiple apps, Czkawka, Nvidia, Windows
("obj", "o"), // Compilators
("odp", "otp"), // LibreOffice
("ods", "ots"), // Libreoffice
("exe", "efi"),
("sh", "sample"), // Git
("exe", "signed"),
("gz", "blend"),
("gz", "crate"),
("gz", "svgz"),
("gz", "tgz"),
("html", "md"),
("html", "svg"), // Quite strange, but yes it works
("jpg", "jfif"),
("mobi", "azw3"),
("obj", "o"),
("obj", "bin"),
("odp", "otp"),
("odt", "ott"),
("ogg", "ogv"),
("pptx", "ppsx"),
("sh", "bash"),
("sh", "py"),
("sh", "pyx"),
("xml", "sopcinfo"), // Quartus
("xml", "bsp"), // Quartus
("xml", "fb2"),
("xml", "user"), // Qtcreator
("sh", "rs"),
("odt", "ott"), // Libreoffice
("ogg", "ogv"), // Audio format
("pptx", "ppsx"), // Powerpoint
("sh", "bash"), // Linux
("sh", "pl"), // Gnome/Linux
("sh", "pm"), // Gnome/Linux
("sh", "py"), // Python
("sh", "pyx"), // Python
("sh", "rs"), // Rust
("sh", "sample"), // Git
("xml", "bsp"), // Quartus
("xml", "cbp"), // CodeBlocks config
("xml", "cmb"),
("xml", "cfg"),
("xml", "conf"),
("xml", "config"),
("xml", "dae"),
("xml", "docbook"),
("xml", "gir"),
("xml", "glade"),
("xml", "html"),
("xml", "kdenlive"),
("xml", "lang"),
("xml", "svg"),
("xml", "ui"), // Cambalache, Glade
("xml", "vcproj"), // VisualStudio
("xml", "cfg"), // Multiple apps - Godot
("xml", "cmb"), // Cambalache
("xml", "conf"), // Multiple apps - Python
("xml", "config"), // Multiple apps - QT Creator
("xml", "dae"), // 3D models
("xml", "docbook"), //
("xml", "fb2"), //
("xml", "gir"), // GTK
("xml", "glade"), // Glade
("xml", "iml"), // Intelij Idea
("xml", "manifest"),
("xml", "xcd"), // Libreoffice files
("xml", "policy"),
("xml", "kdenlive"), // KDenLive
("xml", "lang"), // ?
("xml", "policy"), // SystemD
("xml", "qsys"), // Quartus
("xml", "sopcinfo"), // Quartus
("xml", "svg"), // SVG
("xml", "ui"), // Cambalache, Glade
("xml", "user"), // Qtcreator
("xml", "vbox"), // VirtualBox
("xml", "vbox-prev"), // VirtualBox
("xml", "vcproj"), // VisualStudio
("xml", "xba"), // Libreoffice
("zip", "apk"),
("zip", "doc"),
("zip", "docx"),
("zip", "dat"),
("xml", "xcd"), // Libreoffice files
("zip", "apk"), // Android apk
("zip", "cbr"), // Komiksy
("zip", "dat"), // Multiple - python, brave
("zip", "doc"), // Word
("zip", "docx"), // Word
("zip", "jar"), // Java
("zip", "kra"), // Krita
("zip", "nupkg"),
("zip", "pptx"),
("zip", "whl"),
("zip", "xpi"),
("zip", "zcos"),
("zip", "cbr"), // Komiksy
("zip", "nupkg"), // Nuget packages
("zip", "odg"), // Libreoffice
("zip", "pptx"), // Powerpoint
("zip", "whl"), // Python packages
("zip", "xpi"), // Firefox extensions
("zip", "zcos"), // Scilab
// Probably invalid
("html", "svg"),
("xml", "html"),
// Probably bug in external library
("exe", "doc"), // Not sure whe doc is not recognized
("exe", "xls"), // Not sure whe xls is not recognized
@ -306,10 +315,15 @@ impl BadExtensions {
let mut files_to_check = Default::default();
mem::swap(&mut files_to_check, &mut self.files_to_check);
//// PROGRESS THREAD END
let mut hashmap_workarounds: HashMap<&str, &str> = Default::default();
for (proper, found) in WORKAROUNDS {
hashmap_workarounds.insert(found, proper);
}
self.bad_extensions_files = files_to_check
.into_par_iter() // TODO into par iter after
.into_par_iter()
.map(|file_entry| {
atomic_file_counter.fetch_add(1, Ordering::Relaxed);
if stop_receiver.is_some() && stop_receiver.unwrap().try_recv().is_ok() {
@ -350,7 +364,7 @@ impl BadExtensions {
}
// Check for all extensions that file can use(not sure if it is worth to do it)
let mut all_available_extensions: BTreeSet<_> = Default::default();
let mut all_available_extensions: BTreeSet<&str> = Default::default();
let think_extension = match current_extension.is_empty() {
true => "".to_string(),
false => {
@ -363,9 +377,9 @@ impl BadExtensions {
}
// Workarounds
for (pre, post) in WORKAROUNDS {
if post == &current_extension.as_str() && all_available_extensions.contains(&pre) {
all_available_extensions.insert(post);
if let Some(pre) = hashmap_workarounds.get(current_extension.as_str()) {
if all_available_extensions.contains(pre) {
all_available_extensions.insert(current_extension.as_str());
}
}

View file

@ -1,7 +1,7 @@
use gtk4::prelude::*;
use gtk4::{GestureClick, Widget};
use crate::help_functions::{get_custom_label_from_widget, set_icon_of_button, BottomButtonsEnum};
use crate::help_functions::{get_custom_label_from_widget, get_custom_label_with_name_from_widget, set_icon_of_button, BottomButtonsEnum};
use crate::{
flg, CZK_ICON_COMPARE, CZK_ICON_HARDLINK, CZK_ICON_HIDE_DOWN, CZK_ICON_HIDE_UP, CZK_ICON_MOVE, CZK_ICON_SAVE, CZK_ICON_SEARCH, CZK_ICON_SELECT, CZK_ICON_SYMLINK,
CZK_ICON_TRASH,
@ -96,7 +96,7 @@ impl GuiBottomButtons {
}
pub fn update_language(&self) {
get_custom_label_from_widget(&self.buttons_search.clone()).set_text(&flg!("bottom_search_button"));
get_custom_label_from_widget(&self.buttons_select.clone()).set_text(&flg!("bottom_select_button"));
get_custom_label_with_name_from_widget(&self.buttons_select.clone(), "SelectMenu").set_text(&flg!("bottom_select_button"));
get_custom_label_from_widget(&self.buttons_delete.clone()).set_text(&flg!("bottom_delete_button"));
get_custom_label_from_widget(&self.buttons_save.clone()).set_text(&flg!("bottom_save_button"));
get_custom_label_from_widget(&self.buttons_symlink.clone()).set_text(&flg!("bottom_symlink_button"));

View file

@ -795,6 +795,20 @@ pub fn get_custom_label_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> gtk4::Lab
}
panic!("Button doesn't have proper custom label child");
}
pub fn get_custom_label_with_name_from_widget<P: IsA<gtk4::Widget>>(item: &P, name: &str) -> gtk4::Label {
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];
while let Some(widget) = widgets_to_check.pop() {
if let Ok(label) = widget.clone().downcast::<gtk4::Label>() {
if name == label.text().as_str() {
return label;
}
} else {
widgets_to_check.extend(get_all_children(&widget));
}
}
panic!("Button doesn't have proper custom label child");
}
pub fn get_custom_image_from_widget<P: IsA<gtk4::Widget>>(item: &P) -> gtk4::Image {
let mut widgets_to_check = vec![item.clone().upcast::<gtk4::Widget>()];

View file

@ -346,6 +346,7 @@
(5,4,"GtkPaned","resize-start-child","0",None,None,None,None,None),
(5,4,"GtkPaned","shrink-end-child","0",None,None,None,None,None),
(5,4,"GtkPaned","shrink-start-child","0",None,None,None,None,None),
(5,4,"GtkPaned","wide-handle","True",None,None,None,None,None),
(5,4,"GtkWidget","focusable","1",None,None,None,None,None),
(5,4,"GtkWidget","vexpand","1",None,None,None,None,None),
(5,5,"GtkWidget","focusable","1",None,None,None,None,None),
@ -678,7 +679,7 @@
(5,190,"GtkBox","spacing","2",None,None,None,None,None),
(5,190,"GtkWidget","halign","center",None,None,None,None,None),
(5,191,"GtkImage","icon-name","image-missing",None,None,None,None,None),
(5,192,"GtkLabel","label","Select",1,None,None,None,None),
(5,192,"GtkLabel","label","SelectMenu",None,None,None,None,None),
(5,193,"GtkWidget","focusable","1",None,None,None,None,None),
(5,193,"GtkWidget","receives-default","1",None,None,None,None,None),
(5,194,"GtkBox","spacing","2",None,None,None,None,None),

View file

@ -20,6 +20,7 @@
<property name="shrink-end-child">0</property>
<property name="shrink-start-child">0</property>
<property name="vexpand">1</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkNotebook" id="notebook_upper">
<property name="focusable">1</property>
@ -857,7 +858,7 @@
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Select</property>
<property name="label">SelectMenu</property>
</object>
</child>
</object>