@ -883,15 +883,23 @@ impl Update {
}
}
// Try different temp directories
// Try different temp directories
let tmp_dir_locations = [ "/tmp" , "/var/tmp" , "/dev/shm" ] ;
let tmp_dir_locations = vec! [
Box ::new ( | | Some ( std ::env ::temp_dir ( ) ) ) as Box < dyn FnOnce ( ) -> Option < PathBuf > > ,
Box ::new ( dirs ::cache_dir ) ,
Box ::new ( | | Some ( self . extract_path . parent ( ) . unwrap ( ) . to_path_buf ( ) ) ) ,
] ;
let tmp_dir = tmp_dir_locations
let tmp_dir = tmp_dir_locations
. iter ( )
. into_iter ( )
. find_map ( | dir | {
. find_map ( | loc | {
tempfile ::Builder ::new ( )
if let Some ( path ) = loc ( ) {
. prefix ( "tauri_deb_update" )
tempfile ::Builder ::new ( )
. tempdir_in ( dir )
. prefix ( "tauri_deb_update" )
. ok ( )
. tempdir_in ( path )
. ok ( )
} else {
None
}
} )
} )
. ok_or_else ( | | Error ::TempDirNotFound ) ? ;
. ok_or_else ( | | Error ::TempDirNotFound ) ? ;
@ -901,9 +909,7 @@ impl Update {
std ::fs ::write ( & deb_path , bytes ) ? ;
std ::fs ::write ( & deb_path , bytes ) ? ;
// Try different privilege escalation methods
// Try different privilege escalation methods
let installation_result = self . try_install_with_privileges ( & deb_path ) ;
self . try_install_with_privileges ( & deb_path )
installation_result
}
}
fn try_install_with_privileges ( & self , deb_path : & Path ) -> Result < ( ) > {
fn try_install_with_privileges ( & self , deb_path : & Path ) -> Result < ( ) > {