@@ -22,7 +22,7 @@ pub(crate) async fn install_package(
2222 log_path : & Utf8Path ,
2323) -> Result < ( ) , UpdaterError > {
2424 match ctx. product {
25- Product :: Gateway => install_msi ( ctx, path, log_path) . await ,
25+ Product :: Gateway | Product :: HubService => install_msi ( ctx, path, log_path) . await ,
2626 }
2727}
2828
@@ -32,7 +32,7 @@ pub(crate) async fn uninstall_package(
3232 log_path : & Utf8Path ,
3333) -> Result < ( ) , UpdaterError > {
3434 match ctx. product {
35- Product :: Gateway => uninstall_msi ( ctx, product_code, log_path) . await ,
35+ Product :: Gateway | Product :: HubService => uninstall_msi ( ctx, product_code, log_path) . await ,
3636 }
3737}
3838
@@ -67,14 +67,46 @@ async fn install_msi(ctx: &UpdaterCtx, path: &Utf8Path, log_path: &Utf8Path) ->
6767 }
6868 }
6969
70- if msi_install_result. is_err ( ) {
71- return Err ( UpdaterError :: MsiInstall {
72- product : ctx. product ,
73- msi_path : path. to_owned ( ) ,
74- } ) ;
70+ match msi_install_result {
71+ Ok ( status) => {
72+ let exit_code = status. code ( ) . unwrap_or ( -1 ) ;
73+
74+ // MSI exit codes:
75+ // 0 = Success
76+ // 3010 = Success but reboot required (unexpected - our installers shouldn't require reboot)
77+ // 1641 = Success and reboot initiated
78+ // Other codes = Error
79+ match exit_code {
80+ 0 => {
81+ info ! ( "MSI installation completed successfully" ) ;
82+ Ok ( ( ) )
83+ }
84+ 3010 | 1641 => {
85+ // Our installers should not require a reboot, but if they do, log as warning
86+ // and continue since the installation technically succeeded
87+ warn ! (
88+ %exit_code,
89+ "MSI installation completed but unexpectedly requires system reboot"
90+ ) ;
91+ Ok ( ( ) )
92+ }
93+ _ => {
94+ error ! ( %exit_code, "MSI installation failed with exit code" ) ;
95+ Err ( UpdaterError :: MsiInstall {
96+ product : ctx. product ,
97+ msi_path : path. to_owned ( ) ,
98+ } )
99+ }
100+ }
101+ }
102+ Err ( _) => {
103+ error ! ( "Failed to execute msiexec command" ) ;
104+ Err ( UpdaterError :: MsiInstall {
105+ product : ctx. product ,
106+ msi_path : path. to_owned ( ) ,
107+ } )
108+ }
75109 }
76-
77- Ok ( ( ) )
78110}
79111
80112async fn uninstall_msi ( ctx : & UpdaterCtx , product_code : Uuid , log_path : & Utf8Path ) -> Result < ( ) , UpdaterError > {
@@ -101,14 +133,47 @@ async fn uninstall_msi(ctx: &UpdaterCtx, product_code: Uuid, log_path: &Utf8Path
101133 }
102134 }
103135
104- if msi_uninstall_result. is_err ( ) {
105- return Err ( UpdaterError :: MsiUninstall {
106- product : ctx. product ,
107- product_code,
108- } ) ;
136+ match msi_uninstall_result {
137+ Ok ( status) => {
138+ let exit_code = status. code ( ) . unwrap_or ( -1 ) ;
139+
140+ // MSI exit codes:
141+ // 0 = Success
142+ // 3010 = Success but reboot required (unexpected - our installers shouldn't require reboot)
143+ // 1641 = Success and reboot initiated
144+ // Other codes = Error
145+ match exit_code {
146+ 0 => {
147+ info ! ( %product_code, "MSI uninstallation completed successfully" ) ;
148+ Ok ( ( ) )
149+ }
150+ 3010 | 1641 => {
151+ // Our installers should not require a reboot, but if they do, log as warning
152+ // and continue since the uninstallation technically succeeded
153+ warn ! (
154+ %exit_code,
155+ %product_code,
156+ "MSI uninstallation completed but unexpectedly requires system reboot"
157+ ) ;
158+ Ok ( ( ) )
159+ }
160+ _ => {
161+ error ! ( %exit_code, %product_code, "MSI uninstallation failed with exit code" ) ;
162+ Err ( UpdaterError :: MsiUninstall {
163+ product : ctx. product ,
164+ product_code,
165+ } )
166+ }
167+ }
168+ }
169+ Err ( _) => {
170+ error ! ( %product_code, "Failed to execute msiexec command" ) ;
171+ Err ( UpdaterError :: MsiUninstall {
172+ product : ctx. product ,
173+ product_code,
174+ } )
175+ }
109176 }
110-
111- Ok ( ( ) )
112177}
113178
114179fn ensure_enough_rights ( ) -> Result < ( ) , UpdaterError > {
@@ -159,7 +224,7 @@ fn ensure_enough_rights() -> Result<(), UpdaterError> {
159224
160225pub ( crate ) fn validate_package ( ctx : & UpdaterCtx , path : & Utf8Path ) -> Result < ( ) , UpdaterError > {
161226 match ctx. product {
162- Product :: Gateway => validate_msi ( ctx, path) ,
227+ Product :: Gateway | Product :: HubService => validate_msi ( ctx, path) ,
163228 }
164229}
165230
0 commit comments