@@ -276,9 +276,7 @@ impl UpdaterBuilder {
276276 on_before_exit : self . on_before_exit ,
277277 } )
278278 }
279- }
280279
281- impl UpdaterBuilder {
282280 pub ( crate ) fn current_exe_args < I , S > ( mut self , args : I ) -> Self
283281 where
284282 I : IntoIterator < Item = S > ,
@@ -618,7 +616,13 @@ impl Update {
618616 let updater_type = self . extract ( bytes) ?;
619617
620618 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+
622626 let msi_args;
623627
624628 let installer_args: Vec < & OsStr > = match & updater_type {
@@ -627,25 +631,35 @@ impl Update {
627631 . iter ( )
628632 . map ( OsStr :: new)
629633 . 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+ )
632641 . chain ( self . installer_args ( ) )
633642 . collect ( ) ,
634643 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+ }
641655
642656 [ OsStr :: new ( "/i" ) , path. as_os_str ( ) ]
643657 . into_iter ( )
644658 . chain ( install_mode. msiexec_args ( ) . iter ( ) . map ( OsStr :: new) )
645659 . chain ( once ( OsStr :: new ( "/promptrestart" ) ) )
646660 . chain ( self . installer_args ( ) )
647661 . 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 ( ) ) )
649663 . collect ( )
650664 }
651665 } ;
0 commit comments