@@ -276,9 +276,7 @@ impl UpdaterBuilder {
276
276
on_before_exit : self . on_before_exit ,
277
277
} )
278
278
}
279
- }
280
279
281
- impl UpdaterBuilder {
282
280
pub ( crate ) fn current_exe_args < I , S > ( mut self , args : I ) -> Self
283
281
where
284
282
I : IntoIterator < Item = S > ,
@@ -618,7 +616,13 @@ impl Update {
618
616
let updater_type = self . extract ( bytes) ?;
619
617
620
618
let install_mode = self . config . install_mode ( ) ;
621
- let current_args = & self . current_exe_args ( ) [ 1 ..] ;
619
+ let current_exe_args = self . current_exe_args ( ) ;
620
+ let current_args =
621
+ current_exe_args
622
+ . split_first ( )
623
+ . map ( |( _, args_without_exe) | args_without_exe)
624
+ . unwrap_or ( & [ ] ) ;
625
+
622
626
let msi_args;
623
627
624
628
let installer_args: Vec < & OsStr > = match & updater_type {
@@ -627,25 +631,35 @@ impl Update {
627
631
. iter ( )
628
632
. map ( OsStr :: new)
629
633
. chain ( once ( OsStr :: new ( "/UPDATE" ) ) )
630
- . chain ( once ( OsStr :: new ( "/ARGS" ) ) )
631
- . chain ( current_args. to_vec ( ) )
634
+ . chain (
635
+ if current_args. len ( ) > 0 {
636
+ Some ( once ( OsStr :: new ( "/ARGS" ) ) . chain ( current_args. iter ( ) . map ( |arg| * arg) ) )
637
+ } else {
638
+ None
639
+ } . into_iter ( ) . flatten ( )
640
+ )
632
641
. chain ( self . installer_args ( ) )
633
642
. collect ( ) ,
634
643
WindowsUpdaterType :: Msi { path, .. } => {
635
- let escaped_args = current_args
636
- . iter ( )
637
- . map ( escape_msi_property_arg)
638
- . collect :: < Vec < _ > > ( )
639
- . join ( " " ) ;
640
- msi_args = OsString :: from ( format ! ( "LAUNCHAPPARGS=\" {escaped_args}\" " ) ) ;
644
+ if current_args. len ( ) > 0 {
645
+ let escaped_args = current_args
646
+ . iter ( )
647
+ . map ( escape_msi_property_arg)
648
+ . collect :: < Vec < _ > > ( )
649
+ . join ( " " ) ;
650
+ msi_args = Some ( OsString :: from ( format ! ( "LAUNCHAPPARGS=\" {escaped_args}\" " ) ) ) ;
651
+ }
652
+ else {
653
+ msi_args = None ;
654
+ }
641
655
642
656
[ OsStr :: new ( "/i" ) , path. as_os_str ( ) ]
643
657
. into_iter ( )
644
658
. chain ( install_mode. msiexec_args ( ) . iter ( ) . map ( OsStr :: new) )
645
659
. chain ( once ( OsStr :: new ( "/promptrestart" ) ) )
646
660
. chain ( self . installer_args ( ) )
647
661
. chain ( once ( OsStr :: new ( "AUTOLAUNCHAPP=True" ) ) )
648
- . chain ( once ( msi_args. as_os_str ( ) ) )
662
+ . chain ( msi_args. iter ( ) . map ( |args| args . as_os_str ( ) ) )
649
663
. collect ( )
650
664
}
651
665
} ;
0 commit comments