1
1
use std:: {
2
- env,
3
- ffi:: OsString ,
4
- fs,
2
+ env, fs,
5
3
path:: { Path , PathBuf } ,
6
4
sync:: { Arc , Mutex } ,
7
5
thread:: sleep,
@@ -22,7 +20,7 @@ use crate::{
22
20
packages:: { FilterCondition , PackageQueryBuilder , ProvideStrategy } ,
23
21
} ,
24
22
error:: { ErrorContext , SoarError } ,
25
- utils:: { desktop_dir, icons_dir, process_dir} ,
23
+ utils:: { default_install_excludes , desktop_dir, icons_dir, process_dir} ,
26
24
SoarResult ,
27
25
} ;
28
26
@@ -32,6 +30,7 @@ pub struct PackageInstaller {
32
30
progress_callback : Option < Arc < dyn Fn ( DownloadState ) + Send + Sync > > ,
33
31
db : Arc < Mutex < Connection > > ,
34
32
with_pkg_id : bool ,
33
+ binary_only : bool ,
35
34
}
36
35
37
36
#[ derive( Clone ) ]
@@ -49,6 +48,7 @@ impl PackageInstaller {
49
48
progress_callback : Option < Arc < dyn Fn ( DownloadState ) + Send + Sync > > ,
50
49
db : Arc < Mutex < Connection > > ,
51
50
with_pkg_id : bool ,
51
+ binary_only : bool ,
52
52
) -> SoarResult < Self > {
53
53
let install_dir = install_dir. as_ref ( ) . to_path_buf ( ) ;
54
54
let package = & target. package ;
@@ -90,6 +90,7 @@ impl PackageInstaller {
90
90
progress_callback,
91
91
db : db. clone ( ) ,
92
92
with_pkg_id,
93
+ binary_only,
93
94
} )
94
95
}
95
96
@@ -114,14 +115,27 @@ impl PackageInstaller {
114
115
115
116
if self . package . ghcr_pkg . is_some ( ) {
116
117
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 ( ) ) ;
117
131
let options = OciDownloadOptions {
118
132
url : url. to_string ( ) ,
119
133
output_path : Some ( output_path. to_string_lossy ( ) . to_string ( ) ) ,
120
134
progress_callback : self . progress_callback . clone ( ) ,
121
135
api : None ,
122
136
concurrency : Some ( get_config ( ) . ghcr_concurrency . unwrap_or ( 8 ) ) ,
123
137
regex_patterns : Vec :: new ( ) ,
124
- exclude_keywords : Vec :: new ( ) ,
138
+ exclude_keywords,
125
139
match_keywords : Vec :: new ( ) ,
126
140
exact_case : false ,
127
141
} ;
@@ -335,13 +349,11 @@ impl PackageInstaller {
335
349
let installed_path = PathBuf :: from ( & package. installed_path ) ;
336
350
337
351
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
+ } ) ?;
345
357
}
346
358
}
347
359
Ok ( ( ) )
0 commit comments