Skip to content

Commit 6ddfbb1

Browse files
committed
fix(update): preserve release asset name for verification
1 parent e037733 commit 6ddfbb1

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ members = [
1414
]
1515

1616
[workspace.package]
17-
version = "1.21.3"
17+
version = "1.21.4"
1818
edition = "2024"
1919
authors = ["Terraphim Team <team@terraphim.ai>"]
2020
documentation = "https://terraphim.ai"

crates/terraphim_update/src/lib.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use self_update::version::bump_is_greater;
1919
use std::fmt;
2020
use std::fs;
2121
use std::path::{Path, PathBuf};
22-
use tempfile::NamedTempFile;
22+
use tempfile::TempDir;
2323
use 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

Comments
 (0)