File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " deep-link " : patch
3
+ " deep-link-js " : patch
4
+ ---
5
+
6
+ Fix deep link protocol handler not set as default on linux
7
+ Fix duplicate protocols added to MimeType section in .desktop files on linux
Original file line number Diff line number Diff line change @@ -303,12 +303,14 @@ mod imp {
303
303
304
304
if let Ok ( mut desktop_file) = ini:: Ini :: load_from_file ( & target_file) {
305
305
if let Some ( section) = desktop_file. section_mut ( Some ( "Desktop Entry" ) ) {
306
- let old_mimes = section. remove ( "MimeType" ) ;
307
- section. append (
308
- "MimeType" ,
309
- format ! ( "{mime_type};{}" , old_mimes. unwrap_or_default( ) ) ,
310
- ) ;
311
- desktop_file. write_to_file ( & target_file) ?;
306
+ // it's ok to remove it - we only write to the file if it's missing
307
+ // and in that case we include old_mimes
308
+ let old_mimes = section. remove ( "MimeType" ) . unwrap_or_default ( ) ;
309
+
310
+ if !old_mimes. split ( ';' ) . any ( |mime| mime == mime_type) {
311
+ section. append ( "MimeType" , format ! ( "{mime_type};{old_mimes}" ) ) ;
312
+ desktop_file. write_to_file ( & target_file) ?;
313
+ }
312
314
}
313
315
} else {
314
316
let mut file = File :: create ( target_file) ?;
@@ -333,7 +335,7 @@ mod imp {
333
335
. status ( ) ?;
334
336
335
337
Command :: new ( "xdg-mime" )
336
- . args ( [ "default" , & file_name, _protocol . as_ref ( ) ] )
338
+ . args ( [ "default" , & file_name, mime_type . as_str ( ) ] )
337
339
. status ( ) ?;
338
340
339
341
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments