11use std:: {
2- env,
3- ffi:: OsString ,
4- fs,
2+ env, fs,
53 path:: { Path , PathBuf } ,
64 sync:: { Arc , Mutex } ,
75 thread:: sleep,
@@ -22,7 +20,7 @@ use crate::{
2220 packages:: { FilterCondition , PackageQueryBuilder , ProvideStrategy } ,
2321 } ,
2422 error:: { ErrorContext , SoarError } ,
25- utils:: { desktop_dir, icons_dir, process_dir} ,
23+ utils:: { default_install_excludes , desktop_dir, icons_dir, process_dir} ,
2624 SoarResult ,
2725} ;
2826
@@ -32,6 +30,7 @@ pub struct PackageInstaller {
3230 progress_callback : Option < Arc < dyn Fn ( DownloadState ) + Send + Sync > > ,
3331 db : Arc < Mutex < Connection > > ,
3432 with_pkg_id : bool ,
33+ binary_only : bool ,
3534}
3635
3736#[ derive( Clone ) ]
@@ -49,6 +48,7 @@ impl PackageInstaller {
4948 progress_callback : Option < Arc < dyn Fn ( DownloadState ) + Send + Sync > > ,
5049 db : Arc < Mutex < Connection > > ,
5150 with_pkg_id : bool ,
51+ binary_only : bool ,
5252 ) -> SoarResult < Self > {
5353 let install_dir = install_dir. as_ref ( ) . to_path_buf ( ) ;
5454 let package = & target. package ;
@@ -90,6 +90,7 @@ impl PackageInstaller {
9090 progress_callback,
9191 db : db. clone ( ) ,
9292 with_pkg_id,
93+ binary_only,
9394 } )
9495 }
9596
@@ -114,14 +115,27 @@ impl PackageInstaller {
114115
115116 if self . package . ghcr_pkg . is_some ( ) {
116117 let progress_callback = & self . progress_callback . clone ( ) ;
118+ let exclude_keywords = self
119+ . binary_only
120+ . then_some (
121+ default_install_excludes ( )
122+ . into_iter ( )
123+ . chain (
124+ [ ".png" , ".svg" , "LICENSE" , ".version" , "CHECKSUM" ]
125+ . iter ( )
126+ . map ( |s| s. to_string ( ) ) ,
127+ )
128+ . collect :: < Vec < String > > ( ) ,
129+ )
130+ . unwrap_or_else ( || get_config ( ) . install_excludes . clone ( ) . unwrap_or_default ( ) ) ;
117131 let options = OciDownloadOptions {
118132 url : url. to_string ( ) ,
119133 output_path : Some ( output_path. to_string_lossy ( ) . to_string ( ) ) ,
120134 progress_callback : self . progress_callback . clone ( ) ,
121135 api : None ,
122136 concurrency : Some ( get_config ( ) . ghcr_concurrency . unwrap_or ( 8 ) ) ,
123137 regex_patterns : Vec :: new ( ) ,
124- exclude_keywords : Vec :: new ( ) ,
138+ exclude_keywords,
125139 match_keywords : Vec :: new ( ) ,
126140 exact_case : false ,
127141 } ;
@@ -335,13 +349,11 @@ impl PackageInstaller {
335349 let installed_path = PathBuf :: from ( & package. installed_path ) ;
336350
337351 let mut remove_action = |path : & Path | -> SoarResult < ( ) > {
338- if path. extension ( ) == Some ( & OsString :: from ( "desktop" ) ) {
339- if let Ok ( real_path) = fs:: read_link ( & path) {
340- if real_path. parent ( ) == Some ( & installed_path) {
341- fs:: remove_file ( & path) . with_context ( || {
342- format ! ( "removing desktop file {}" , path. display( ) )
343- } ) ?;
344- }
352+ if let Ok ( real_path) = fs:: read_link ( & path) {
353+ if real_path. parent ( ) == Some ( & installed_path) {
354+ fs:: remove_file ( & path) . with_context ( || {
355+ format ! ( "removing desktop file {}" , path. display( ) )
356+ } ) ?;
345357 }
346358 }
347359 Ok ( ( ) )
0 commit comments