@@ -19,7 +19,7 @@ use self_update::version::bump_is_greater;
1919use std:: fmt;
2020use std:: fs;
2121use std:: path:: { Path , PathBuf } ;
22- use tempfile:: NamedTempFile ;
22+ use tempfile:: TempDir ;
2323use tracing:: { error, info, warn} ;
2424
2525/// Represents the status of an update operation
@@ -493,7 +493,7 @@ impl TerraphimUpdater {
493493 let latest_version = & release. version ;
494494
495495 // Step 2: Download archive to temp location
496- let temp_archive = match Self :: download_release_archive (
496+ let ( _temp_dir , archive_path ) = match Self :: download_release_archive (
497497 repo_owner,
498498 repo_name,
499499 bin_name,
@@ -509,8 +509,6 @@ impl TerraphimUpdater {
509509 }
510510 } ;
511511
512- let archive_path = temp_archive. path ( ) . to_path_buf ( ) ;
513-
514512 // Step 3: Verify signature BEFORE installation
515513 info ! ( "Verifying signature for archive {:?}" , archive_path) ;
516514 let verification_result =
@@ -605,7 +603,7 @@ impl TerraphimUpdater {
605603 bin_name : & str ,
606604 version : & str ,
607605 show_progress : bool ,
608- ) -> Result < NamedTempFile > {
606+ ) -> Result < ( TempDir , PathBuf ) > {
609607 // Normalize binary name (replace underscores with hyphens for GitHub releases)
610608 let bin_name_in_asset = bin_name. replace ( '_' , "-" ) ;
611609
@@ -633,25 +631,26 @@ impl TerraphimUpdater {
633631
634632 info ! ( "Trying to download from: {}" , download_url) ;
635633
636- // Create temp file for download
637- let temp_file = NamedTempFile :: new ( ) ?;
634+ // zipsign uses the filename as signature context, so preserve
635+ // the release asset filename instead of using a random temp name.
636+ let temp_dir = tempfile:: tempdir ( ) ?;
637+ let archive_path = temp_dir. path ( ) . join ( & asset_name) ;
638638 let download_config = crate :: downloader:: DownloadConfig {
639639 show_progress,
640640 ..Default :: default ( )
641641 } ;
642642
643643 match crate :: downloader:: download_with_retry (
644644 & download_url,
645- temp_file . path ( ) ,
645+ & archive_path ,
646646 Some ( download_config) ,
647647 ) {
648648 Ok ( _) => {
649649 info ! (
650650 "Successfully downloaded {} to: {:?}" ,
651- asset_name,
652- temp_file. path( )
651+ asset_name, archive_path
653652 ) ;
654- return Ok ( temp_file ) ;
653+ return Ok ( ( temp_dir , archive_path ) ) ;
655654 }
656655 Err ( e) => {
657656 info ! ( "Failed to download {}: {}" , asset_name, e) ;
0 commit comments