@@ -13,13 +13,6 @@ use crate::events::{
1313#[ serde( tag = "kind" , rename_all = "snake_case" ) ]
1414pub enum InstallResult {
1515 RelaunchCurrent ,
16- MacosBundleUpdate {
17- current_path : String ,
18- staged_path : String ,
19- target_path : String ,
20- backup_path : String ,
21- stage_dir : String ,
22- } ,
2316}
2417
2518pub struct Updater2 < ' a , R : tauri:: Runtime , M : tauri:: Manager < R > > {
@@ -189,79 +182,16 @@ impl<'a, R: tauri::Runtime, M: tauri::Manager<R>> Updater2<'a, R, M> {
189182 let _ = store. save ( ) ;
190183 }
191184
192- #[ cfg( target_os = "macos" ) ]
193- {
194- let stage_dir = self . create_macos_update_stage_dir ( version) ?;
195- let staged_update = match crate :: migration:: stage_macos_update ( & bytes, & stage_dir) {
196- Ok ( staged_update) => staged_update,
197- Err ( err) => {
198- let _ = std:: fs:: remove_dir_all ( & stage_dir) ;
199- return Err ( err) ;
200- }
201- } ;
202-
203- Ok ( InstallResult :: MacosBundleUpdate {
204- current_path : staged_update. current_app_path . display ( ) . to_string ( ) ,
205- staged_path : staged_update. staged_app_path . display ( ) . to_string ( ) ,
206- target_path : staged_update. target_app_path . display ( ) . to_string ( ) ,
207- backup_path : staged_update. current_backup_path . display ( ) . to_string ( ) ,
208- stage_dir : staged_update. stage_dir . display ( ) . to_string ( ) ,
209- } )
210- }
211-
212- #[ cfg( not( target_os = "macos" ) ) ]
213- {
214- update. install ( & bytes) ?;
215- Ok ( InstallResult :: RelaunchCurrent )
216- }
185+ update. install ( & bytes) ?;
186+ Ok ( InstallResult :: RelaunchCurrent )
217187 }
218188
219189 pub async fn postinstall ( & self , result : InstallResult ) -> Result < ( ) , crate :: Error > {
220190 match result {
221191 InstallResult :: RelaunchCurrent => {
222192 self . manager . app_handle ( ) . restart ( ) ;
223193 }
224- InstallResult :: MacosBundleUpdate {
225- current_path,
226- staged_path,
227- target_path,
228- backup_path,
229- stage_dir,
230- } => {
231- #[ cfg( target_os = "macos" ) ]
232- {
233- let handle = self . manager . app_handle ( ) . clone ( ) ;
234- let current_pid = std:: process:: id ( ) ;
235-
236- crate :: migration:: schedule_macos_update_after_exit (
237- current_pid,
238- crate :: migration:: StagedMacosUpdate {
239- current_app_path : PathBuf :: from ( current_path) ,
240- staged_app_path : PathBuf :: from ( staged_path) ,
241- target_app_path : PathBuf :: from ( target_path) ,
242- current_backup_path : PathBuf :: from ( backup_path) ,
243- stage_dir : PathBuf :: from ( stage_dir) ,
244- } ,
245- ) ?;
246-
247- handle. exit ( 0 ) ;
248- }
249- #[ cfg( not( target_os = "macos" ) ) ]
250- {
251- let _ = (
252- current_path,
253- staged_path,
254- target_path,
255- backup_path,
256- stage_dir,
257- ) ;
258- return Err ( crate :: Error :: InvalidPostinstallState (
259- "macos_bundle_update is only valid on macOS" . into ( ) ,
260- ) ) ;
261- }
262- }
263194 }
264- Ok ( ( ) )
265195 }
266196}
267197
@@ -295,48 +225,3 @@ fn get_cache_path<R: tauri::Runtime, M: tauri::Manager<R>>(
295225 . map ( |p : PathBuf | p. join ( "updates" ) ) ?;
296226 Some ( dir. join ( format ! ( "{}.bin" , version) ) )
297227}
298-
299- #[ cfg( target_os = "macos" ) ]
300- impl < ' a , R : tauri:: Runtime , M : tauri:: Manager < R > > Updater2 < ' a , R , M > {
301- fn create_macos_update_stage_dir ( & self , version : & str ) -> Result < PathBuf , crate :: Error > {
302- let base_dir = self
303- . manager
304- . app_handle ( )
305- . path ( )
306- . app_cache_dir ( )
307- . map_err ( |_| crate :: Error :: CachePathUnavailable ) ?
308- . join ( "updates" )
309- . join ( "staged" ) ;
310- std:: fs:: create_dir_all ( & base_dir) ?;
311-
312- let version = sanitize_path_component ( version) ;
313- let current_pid = std:: process:: id ( ) ;
314-
315- for attempt in 0 ..100 {
316- let nanos = std:: time:: SystemTime :: now ( )
317- . duration_since ( std:: time:: UNIX_EPOCH )
318- . unwrap_or_default ( )
319- . as_nanos ( ) ;
320- let stage_dir = base_dir. join ( format ! ( "{version}-{current_pid}-{nanos}-{attempt}" ) ) ;
321-
322- match std:: fs:: create_dir ( & stage_dir) {
323- Ok ( ( ) ) => return Ok ( stage_dir) ,
324- Err ( err) if err. kind ( ) == std:: io:: ErrorKind :: AlreadyExists => continue ,
325- Err ( err) => return Err ( err. into ( ) ) ,
326- }
327- }
328-
329- Err ( crate :: Error :: CachePathUnavailable )
330- }
331- }
332-
333- #[ cfg( target_os = "macos" ) ]
334- fn sanitize_path_component ( value : & str ) -> String {
335- value
336- . chars ( )
337- . map ( |ch| match ch {
338- 'a' ..='z' | 'A' ..='Z' | '0' ..='9' | '-' | '_' | '.' => ch,
339- _ => '_' ,
340- } )
341- . collect ( )
342- }
0 commit comments