From 783603b376bc9cf36fefce0fb639950667212fb8 Mon Sep 17 00:00:00 2001 From: amr-crabnebula Date: Wed, 6 Sep 2023 21:55:20 +0300 Subject: [PATCH] fix: clippy lints --- crates/packager/src/config.rs | 6 +++--- crates/packager/src/error.rs | 2 +- crates/packager/src/lib.rs | 12 ++++++------ crates/packager/src/nsis/mod.rs | 2 +- crates/packager/src/util.rs | 2 +- crates/packager/src/wix/mod.rs | 9 ++++++--- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/crates/packager/src/config.rs b/crates/packager/src/config.rs index 85878f22..38ff0d18 100644 --- a/crates/packager/src/config.rs +++ b/crates/packager/src/config.rs @@ -89,7 +89,7 @@ impl ConfigExtInternal for Config { src.ok().and_then(|src| { use relative_path::PathExt; let src = - dunce::canonicalize(&src).expect("failed to canonicalize path"); + dunce::canonicalize(src).expect("failed to canonicalize path"); let target = src.relative_to(&cwd); target.ok().map(|target| Resource { src, @@ -101,10 +101,10 @@ impl ConfigExtInternal for Config { } Resources::Map(m) => { for (src, target) in m.iter() { - out.extend(glob::glob(&src).unwrap().filter_map(|src| { + out.extend(glob::glob(src).unwrap().filter_map(|src| { src.ok().map(|src| { let src = - dunce::canonicalize(&src).expect("failed to canonicalize path"); + dunce::canonicalize(src).expect("failed to canonicalize path"); let target = PathBuf::from(target).join( src.file_name() .expect("Failed to get filename of a resource file"), diff --git a/crates/packager/src/error.rs b/crates/packager/src/error.rs index eafb3712..4d931b47 100644 --- a/crates/packager/src/error.rs +++ b/crates/packager/src/error.rs @@ -33,7 +33,7 @@ pub enum Error { ZipError(#[from] zip::result::ZipError), /// Zip error. #[error(transparent)] - DownloadError(#[from] ureq::Error), + DownloadError(#[from] Box), /// Unsupported OS bitness. #[error("unsupported OS bitness")] UnsupportedBitness, diff --git a/crates/packager/src/lib.rs b/crates/packager/src/lib.rs index 208c019d..ab48b130 100644 --- a/crates/packager/src/lib.rs +++ b/crates/packager/src/lib.rs @@ -69,11 +69,11 @@ fn cross_command(script: &str) -> Command { #[cfg(windows)] let mut cmd = Command::new("cmd"); #[cfg(windows)] - cmd.arg("/S").arg("/C").arg(&script); + cmd.arg("/S").arg("/C").arg(script); #[cfg(not(windows))] let mut cmd = Command::new("sh"); #[cfg(not(windows))] - cmd.arg("-c").arg(&script); + cmd.arg("-c").arg(script); cmd } @@ -100,11 +100,11 @@ pub fn package(config: &Config) -> Result> { if let Some(hook) = &config.before_packaging_command { let (mut cmd, script) = match hook { cargo_packager_config::HookCommand::Script(script) => { - let cmd = cross_command(&script); + let cmd = cross_command(script); (cmd, script) } cargo_packager_config::HookCommand::ScriptWithOptions { script, dir } => { - let mut cmd = cross_command(&script); + let mut cmd = cross_command(script); if let Some(dir) = dir { cmd.current_dir(dir); } @@ -129,11 +129,11 @@ pub fn package(config: &Config) -> Result> { if let Some(hook) = &config.before_each_package_command { let (mut cmd, script) = match hook { cargo_packager_config::HookCommand::Script(script) => { - let cmd = cross_command(&script); + let cmd = cross_command(script); (cmd, script) } cargo_packager_config::HookCommand::ScriptWithOptions { script, dir } => { - let mut cmd = cross_command(&script); + let mut cmd = cross_command(script); if let Some(dir) = dir { cmd.current_dir(dir); } diff --git a/crates/packager/src/nsis/mod.rs b/crates/packager/src/nsis/mod.rs index 18eb3cb8..d3392de6 100644 --- a/crates/packager/src/nsis/mod.rs +++ b/crates/packager/src/nsis/mod.rs @@ -73,7 +73,7 @@ fn generate_binaries_data(config: &Config) -> crate::Result { if let Some(external_binaries) = &config.external_binaries { for src in external_binaries { - let binary_path = dunce::canonicalize(cwd.join(&src))?; + let binary_path = dunce::canonicalize(cwd.join(src))?; let dest_filename = binary_path .file_name() .expect("failed to extract external binary filename") diff --git a/crates/packager/src/util.rs b/crates/packager/src/util.rs index ff06ebf8..d18a039c 100644 --- a/crates/packager/src/util.rs +++ b/crates/packager/src/util.rs @@ -70,7 +70,7 @@ pub fn target_triple() -> crate::Result { pub(crate) fn download(url: &str) -> crate::Result> { log::info!(action = "Downloading"; "{}", url); - let response = ureq::get(url).call()?; + let response = ureq::get(url).call().map_err(Box::new)?; let mut bytes = Vec::new(); response.into_reader().read_to_end(&mut bytes)?; Ok(bytes) diff --git a/crates/packager/src/wix/mod.rs b/crates/packager/src/wix/mod.rs index 333d78b6..9cf922c9 100644 --- a/crates/packager/src/wix/mod.rs +++ b/crates/packager/src/wix/mod.rs @@ -132,7 +132,7 @@ fn generate_binaries_data(config: &Config) -> crate::Result> { if let Some(external_binaries) = &config.external_binaries { for src in external_binaries { - let binary_path = cwd.join(&src); + let binary_path = cwd.join(src); let dest_filename = PathBuf::from(src) .file_name() .expect("failed to extract external binary filename") @@ -411,7 +411,6 @@ fn clear_env_for_wix(cmd: &mut Command) { /// Runs the Candle.exe executable for Wix. Candle parses the wxs file and generates the code for building the installer. fn run_candle( config: &Config, - main_binary: &crate::config::Binary, arch: &str, wix_toolset_path: &Path, cwd: &Path, @@ -419,6 +418,11 @@ fn run_candle( extensions: Vec, log_level: LogLevel, ) -> crate::Result<()> { + let main_binary = config + .binaries + .iter() + .find(|bin| bin.main) + .ok_or_else(|| crate::Error::MainBinaryNotFound)?; let mut args = vec![ "-arch".to_string(), arch.to_string(), @@ -747,7 +751,6 @@ fn build_wix_app_installer( } run_candle( config, - main_binary, arch, wix_toolset_path, &output_path,