@@ -792,53 +792,6 @@ impl App {
792792 ' outer: for ( mime, paths) in groups {
793793 log:: debug!( "Attempting to launch app\n \t for: {mime}\n \t with: {paths:?}" ) ;
794794
795- // ---- archives ----
796- if supported_archive_types. iter ( ) . copied ( ) . any ( |t| mime == t) {
797-
798- // Checks if there are suitable apps for archives
799- let mut found_archive_app = false ;
800- for app in self . mime_app_cache . get ( & mime) {
801- log:: debug!( "Checking app {} for archive support" , app. id) ;
802- if Self :: is_suitable_archive_app ( app) {
803- found_archive_app = true ;
804- log:: debug!( "Found suitable archive app {} for MIME {}" , app. id, mime) ;
805-
806- // Immediately launch the app we found
807- if let Some ( mut commands) = app. command ( & paths) {
808- for mut command in commands. drain ( ..) {
809- match spawn_detached ( & mut command) {
810- Ok ( ( ) ) => {
811- log:: debug!( "Launched {} with {:?}" , app. id, paths) ;
812- // Updates recently_used
813- for path in & paths {
814- let _ = recently_used_xbel:: update_recently_used (
815- path,
816- Self :: APP_ID . to_string ( ) ,
817- "cosmic-files" . to_string ( ) ,
818- None ,
819- ) ;
820- }
821- }
822- Err ( err) => {
823- log:: warn!( "Failed to launch {} for {:?}: {}" , app. id, paths, err) ;
824- // TODO: maybe if it fails to launch, fallback to extract_to? by settings found_archive_app = false
825- }
826- }
827- }
828- }
829- break ;
830- }
831- }
832-
833- if !found_archive_app {
834- log:: info!( "No suitable archive app found for MIME {}. Falling back to extract_to." , mime) ;
835- found_archives_paths. extend ( paths. iter ( ) . cloned ( ) ) ;
836- }
837-
838- continue ' outer;
839-
840- }
841-
842795 // First launch apps that can be launched directly
843796 if mime == "application/x-desktop" {
844797 // Try opening desktop application
@@ -865,6 +818,33 @@ impl App {
865818 }
866819 }
867820 continue ;
821+ } else if supported_archive_types. iter ( ) . copied ( ) . any ( |t| mime == t) { // Archives handling
822+
823+ let mut found_archive_app = false ;
824+
825+ // Checks if there are suitable apps for archives (if cosmic-files is the dafult one, fallback to extract_to)
826+ for app in self . mime_app_cache . get ( & mime) {
827+ if app. id == Self :: APP_ID {
828+ log:: debug!( "Default app is cosmic-files, adding to extract_to dialog" ) ;
829+ found_archive_app = false ; // Let's confirm we want the extrac_to dialog in this case
830+ break ; // Stop looking
831+ } else {
832+ log:: debug!( "Found suitable archive app {} for MIME {}" , app. id, mime) ;
833+
834+ if self . launch_from_mime_cache ( & mime, & paths) {
835+ found_archive_app = true ; // Not adding to extract_to list
836+ break ;
837+ } else {
838+ found_archive_app = false ; // Adding to extract_to list because unable to open (fallback)
839+ }
840+ }
841+ }
842+
843+ if !found_archive_app {
844+ found_archives_paths. extend ( paths. iter ( ) . cloned ( ) ) ;
845+ }
846+
847+ continue ' outer;
868848 }
869849
870850 // Try mime apps, which should be faster than xdg-open
@@ -901,6 +881,8 @@ impl App {
901881 }
902882 }
903883
884+ // We are done with looping through file groups, let's see if there are archives to
885+ // open with the extract_to dialog
904886 if found_archives_paths. len ( ) > 0 {
905887 log:: debug!( "Paths to extract with dialog: {:?}" , found_archives_paths) ;
906888 tasks. push ( self . extract_to ( & found_archives_paths) ) ;
@@ -909,28 +891,6 @@ impl App {
909891 Task :: batch ( tasks)
910892 }
911893
912- fn is_suitable_archive_app ( app : & MimeApp ) -> bool {
913-
914- if app. no_display {
915- return false ;
916- }
917-
918- let has = |cat : & str | app. categories . iter ( ) . any ( |c| c == cat) ;
919-
920- // semantic exclusions
921- if has ( "FileManager" ) || has ( "WebBrowser" ) {
922- return false ;
923- }
924-
925- // if it is an archiver, yes!
926- if has ( "Archiver" ) {
927- return true ;
928- }
929-
930- // optional (conservative)
931- has ( "Utility" ) && has ( "Compression" )
932- }
933-
934894 fn launch_desktop_entries ( paths : & [ impl AsRef < Path > ] ) {
935895 for path in paths. iter ( ) . map ( AsRef :: as_ref) {
936896 match DesktopEntry :: from_path :: < & str > ( path, None ) {
@@ -3144,6 +3104,7 @@ impl Application for App {
31443104 if let Some ( archive_paths) = archive_paths
31453105 && !selected_paths. is_empty ( )
31463106 {
3107+ log:: debug!( "archive_paths is {:?}" , archive_paths) ;
31473108 self . file_dialog_opt = None ;
31483109 return self . operation ( Operation :: Extract {
31493110 paths : archive_paths,
0 commit comments