@@ -297,13 +297,6 @@ impl UpdaterBuilder {
297
297
} ;
298
298
299
299
let arch = get_updater_arch ( ) . ok_or ( Error :: UnsupportedArch ) ?;
300
- let ( target, json_target) = if let Some ( target) = self . target {
301
- ( target. clone ( ) , target)
302
- } else {
303
- let target = get_updater_target ( ) . ok_or ( Error :: UnsupportedOs ) ?;
304
- let json_target = format ! ( "{target}-{arch}" ) ;
305
- ( target. to_owned ( ) , json_target)
306
- } ;
307
300
308
301
let executable_path = self . executable_path . clone ( ) . unwrap_or ( current_exe ( ) ?) ;
309
302
@@ -326,8 +319,7 @@ impl UpdaterBuilder {
326
319
installer_args : self . installer_args ,
327
320
current_exe_args : self . current_exe_args ,
328
321
arch,
329
- target,
330
- json_target,
322
+ target : self . target ,
331
323
headers : self . headers ,
332
324
extract_path,
333
325
on_before_exit : self . on_before_exit ,
@@ -359,10 +351,7 @@ pub struct Updater {
359
351
proxy : Option < Url > ,
360
352
endpoints : Vec < Url > ,
361
353
arch : & ' static str ,
362
- // The `{{target}}` variable we replace in the endpoint and serach for in the JSON
363
- target : String ,
364
- // The value we search if the updater server returns a JSON with the `platforms` object
365
- json_target : String ,
354
+ target : Option < String > ,
366
355
headers : HeaderMap ,
367
356
extract_path : PathBuf ,
368
357
on_before_exit : Option < OnBeforeExit > ,
@@ -403,6 +392,13 @@ impl Updater {
403
392
std:: env:: set_var ( "SSL_CERT_DIR" , "/etc/ssl/certs" ) ;
404
393
}
405
394
}
395
+ let ( target, json_target) = if let Some ( target) = & self . target {
396
+ ( target. clone ( ) , target. clone ( ) )
397
+ } else {
398
+ let target = get_updater_target ( ) . ok_or ( Error :: UnsupportedOs ) ?;
399
+ let json_target = format ! ( "{target}-{}" , self . arch) ;
400
+ ( target. to_owned ( ) , json_target)
401
+ } ;
406
402
407
403
let mut remote_release: Option < RemoteRelease > = None ;
408
404
let mut raw_json: Option < serde_json:: Value > = None ;
@@ -425,11 +421,11 @@ impl Updater {
425
421
. to_string ( )
426
422
// url::Url automatically url-encodes the path components
427
423
. replace ( "%7B%7Bcurrent_version%7D%7D" , & encoded_version)
428
- . replace ( "%7B%7Btarget%7D%7D" , & self . target )
424
+ . replace ( "%7B%7Btarget%7D%7D" , & target)
429
425
. replace ( "%7B%7Barch%7D%7D" , self . arch )
430
426
// but not query parameters
431
427
. replace ( "{{current_version}}" , & encoded_version)
432
- . replace ( "{{target}}" , & self . target )
428
+ . replace ( "{{target}}" , & target)
433
429
. replace ( "{{arch}}" , self . arch )
434
430
. parse ( ) ?;
435
431
@@ -510,13 +506,13 @@ impl Updater {
510
506
None => release. version > self . current_version ,
511
507
} ;
512
508
513
- let mut download_url = release. download_url ( & self . json_target ) ;
514
- let mut signature = release. signature ( & self . json_target ) ;
509
+ let mut download_url = release. download_url ( & json_target) ;
510
+ let mut signature = release. signature ( & json_target) ;
515
511
516
512
let installer = self . get_updater_installer ( ) ;
517
513
518
514
if let Some ( installer) = installer {
519
- let target = & format ! ( "{}-{}" , & self . json_target, installer. suffix( ) ) ;
515
+ let target = & format ! ( "{}-{}" , & json_target, installer. suffix( ) ) ;
520
516
log:: debug!(
521
517
"Bundle type is {}. Checking for plattform {target} in response" ,
522
518
installer. suffix( )
@@ -525,10 +521,7 @@ impl Updater {
525
521
let bundle_signature = release. signature ( target) ;
526
522
if bundle_url. is_err ( ) || bundle_signature. is_err ( ) {
527
523
if download_url. is_err ( ) || signature. is_err ( ) {
528
- return Err ( Error :: TargetsNotFound (
529
- self . json_target . clone ( ) ,
530
- target. clone ( ) ,
531
- ) ) ;
524
+ return Err ( Error :: TargetsNotFound ( json_target. clone ( ) , target. clone ( ) ) ) ;
532
525
}
533
526
log:: debug!( "Plattform {target} not found in response. Using fallback URL" ) ;
534
527
} else {
@@ -537,11 +530,8 @@ impl Updater {
537
530
signature = bundle_signature;
538
531
}
539
532
} else if download_url. is_err ( ) || signature. is_err ( ) {
540
- log:: debug!(
541
- "Bundle type is not known and fallback platform {} was not found in response" ,
542
- self . json_target
543
- ) ;
544
- return Err ( Error :: TargetNotFound ( self . json_target . clone ( ) ) ) ;
533
+ log:: debug!( "Bundle type is not known and fallback platform {json_target} was not found in response" ) ;
534
+ return Err ( Error :: TargetNotFound ( json_target. clone ( ) ) ) ;
545
535
}
546
536
547
537
let update = if should_update {
@@ -551,7 +541,6 @@ impl Updater {
551
541
on_before_exit : self . on_before_exit . clone ( ) ,
552
542
app_name : self . app_name . clone ( ) ,
553
543
current_version : self . current_version . to_string ( ) ,
554
- target : self . target . clone ( ) ,
555
544
extract_path : self . extract_path . clone ( ) ,
556
545
version : release. version . to_string ( ) ,
557
546
date : release. pub_date ,
@@ -590,8 +579,6 @@ pub struct Update {
590
579
pub version : String ,
591
580
/// Update publish date
592
581
pub date : Option < OffsetDateTime > ,
593
- /// Target
594
- pub target : String ,
595
582
/// Current installer
596
583
pub installer : Option < Installer > ,
597
584
/// Download URL announced
0 commit comments