Sfoglia il codice sorgente

fix(cli): only try to read updater private key if we've bundled it

Lucas Nogueira 3 anni fa
parent
commit
816f474c3e
2 ha cambiato i file con 11 aggiunte e 24 eliminazioni
  1. 2 14
      tooling/cli/Cargo.lock
  2. 9 10
      tooling/cli/src/build.rs

+ 2 - 14
tooling/cli/Cargo.lock

@@ -1122,9 +1122,9 @@ dependencies = [
 
 [[package]]
 name = "image"
-version = "0.24.2"
+version = "0.24.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28edd9d7bc256be2502e325ac0628bde30b7001b9b52e0abe31a1a9dc2701212"
+checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964"
 dependencies = [
  "bytemuck",
  "byteorder",
@@ -1132,7 +1132,6 @@ dependencies = [
  "exr",
  "gif",
  "jpeg-decoder",
- "num-iter",
  "num-rational",
  "num-traits",
  "png 0.17.5",
@@ -1691,17 +1690,6 @@ dependencies = [
  "num-traits",
 ]
 
-[[package]]
-name = "num-iter"
-version = "0.1.43"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
-dependencies = [
- "autocfg",
- "num-integer",
- "num-traits",
-]
-
 [[package]]
 name = "num-rational"
 version = "0.4.1"

+ 9 - 10
tooling/cli/src/build.rs

@@ -21,7 +21,7 @@ use std::{
   path::{Path, PathBuf},
   process::Command,
 };
-use tauri_bundler::bundle::{bundle_project, PackageType};
+use tauri_bundler::bundle::{bundle_project, Bundle, PackageType};
 
 #[derive(Debug, Clone, Parser)]
 #[clap(about = "Tauri build")]
@@ -278,8 +278,12 @@ pub fn command(mut options: Options) -> Result<()> {
 
     let bundles = bundle_project(settings).with_context(|| "failed to bundle project")?;
 
-    // If updater is active
-    if config_.tauri.updater.active {
+    let updater_bundles: Vec<&Bundle> = bundles
+      .iter()
+      .filter(|bundle| bundle.package_type == PackageType::Updater)
+      .collect();
+    // If updater is active and we bundled it
+    if config_.tauri.updater.active && !updater_bundles.is_empty() {
       // if no password provided we use an empty string
       let password = var_os("TAURI_KEY_PASSWORD").map(|v| v.to_str().unwrap().to_string());
       // get the private key
@@ -305,10 +309,7 @@ pub fn command(mut options: Options) -> Result<()> {
 
       // make sure we have our package builts
       let mut signed_paths = Vec::new();
-      for elem in bundles
-        .iter()
-        .filter(|bundle| bundle.package_type == PackageType::Updater)
-      {
+      for elem in updater_bundles {
         // we expect to have only one path in the vec but we iter if we add
         // another type of updater package who require multiple file signature
         for path in elem.bundle_paths.iter() {
@@ -323,9 +324,7 @@ pub fn command(mut options: Options) -> Result<()> {
         }
       }
 
-      if !signed_paths.is_empty() {
-        print_signed_updater_archive(&signed_paths)?;
-      }
+      print_signed_updater_archive(&signed_paths)?;
     }
   }