From 640825987ce75d17f203adcb126b3ab2242bbadb Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 30 Jul 2024 14:47:18 +0200 Subject: [PATCH] Fix clippy warnings --- src/api/build.rs | 22 +++++++++------------- src/api/delta.rs | 3 +-- src/app.rs | 2 +- src/jobs/publish_job.rs | 4 ++-- src/ostree.rs | 12 ++++++------ 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/api/build.rs b/src/api/build.rs index 7413602..6084db5 100644 --- a/src/api/build.rs +++ b/src/api/build.rs @@ -126,7 +126,7 @@ async fn create_build_async( req.has_token_prefix(app_id)?; } - let repoconfig = config.get_repoconfig(&args.repo).map(|rc| rc.clone())?; // Ensure the repo exists + let repoconfig = config.get_repoconfig(&args.repo).cloned()?; // Ensure the repo exists // If public_download is not specified, it defaults to true if there is no app ID (old style builds) and false // if there is one. @@ -150,18 +150,14 @@ async fn create_build_async( None }; - let token_branches = if let Some(ref claims) = req.get_claims() { - Some( - claims - .branches - .iter() - .filter(|s| !s.is_empty()) - .map(|s| s.clone()) - .collect(), - ) - } else { - None - }; + let token_branches = req.get_claims().map(|claims| { + claims + .branches + .iter() + .filter(|s| !s.is_empty()) + .cloned() + .collect() + }); let build = db .new_build(NewBuild { diff --git a/src/api/delta.rs b/src/api/delta.rs index cd14094..100511d 100644 --- a/src/api/delta.rs +++ b/src/api/delta.rs @@ -6,7 +6,6 @@ use actix_web_actors::ws; use futures::future::Future; use serde::Deserialize; -use std::clone::Clone; use std::sync::Arc; use crate::config::Config; @@ -28,7 +27,7 @@ pub fn delta_upload( config: Data, ) -> impl Future { futures::done(req.has_token_claims("delta", ClaimsScope::Generate)) - .and_then(move |_| futures::done(config.get_repoconfig(¶ms.repo).map(|rc| rc.clone()))) + .and_then(move |_| futures::done(config.get_repoconfig(¶ms.repo).cloned())) .and_then(move |repoconfig| { let uploadstate = Arc::new(UploadState { only_deltas: true, diff --git a/src/app.rs b/src/app.rs index 784267d..ca7cb28 100644 --- a/src/app.rs +++ b/src/app.rs @@ -50,7 +50,7 @@ pub fn load_config>(path: P) -> io::Result { config_data.build_gpg_key_content = load_gpg_key(&config_data.gpg_homedir, &config_data.build_gpg_key)?; for (reponame, repoconfig) in &mut config_data.repos { - repoconfig.name = reponame.clone(); + reponame.clone_into(&mut repoconfig.name); repoconfig.gpg_key_content = load_gpg_key(&config_data.gpg_homedir, &config_data.build_gpg_key)?; } diff --git a/src/jobs/publish_job.rs b/src/jobs/publish_job.rs index 6c54d84..2f5612d 100644 --- a/src/jobs/publish_job.rs +++ b/src/jobs/publish_job.rs @@ -144,11 +144,11 @@ impl PublishJobInstance { job_log_and_info!( self.job_id, conn, - &format!("Removing build {}", self.build_id.to_string()), + &format!("Removing build {}", self.build_id), ); fs::remove_dir_all(path).unwrap_or_else(|_| { - job_log_and_info!(self.job_id, conn, &format!("Failed to remove build")); + job_log_and_info!(self.job_id, conn, "Failed to remove build"); }); Ok(json!({ diff --git a/src/ostree.rs b/src/ostree.rs index fa5dafb..0e001d3 100644 --- a/src/ostree.rs +++ b/src/ostree.rs @@ -12,10 +12,10 @@ use std::path; use std::path::PathBuf; use std::process::Command; use std::str; +use std::thread::sleep; use std::time::Duration; use std::{collections::HashMap, path::Path}; use std::{fs, io}; -use std::thread::sleep; use tokio_process::CommandExt; use walkdir::WalkDir; @@ -208,11 +208,11 @@ impl<'a> SubVariant<'a> { let len = self.data.len() as u64; if len == 0 { 0 - } else if len <= ::std::u8::MAX as u64 { + } else if len <= u8::MAX as u64 { 1 - } else if len <= ::std::u16::MAX as u64 { + } else if len <= u16::MAX as u64 { 2 - } else if len <= ::std::u32::MAX as u64 { + } else if len <= u32::MAX as u64 { 4 } else { 8 @@ -232,7 +232,7 @@ impl<'a> SubVariant<'a> { 4 => LittleEndian::read_u32(data) as usize, 8 => { let len64 = LittleEndian::read_u64(data); - if len64 > ::std::usize::MAX as u64 { + if len64 > usize::MAX as u64 { return Err(OstreeError::InternalError( "Framing error: To large framing size fror usize".to_string(), )); @@ -977,7 +977,7 @@ pub fn pull_commit_async( e.to_string() ); let sleep_duration = Duration::from_secs(5); - let _ = sleep(sleep_duration); + sleep(sleep_duration); Ok(future::Loop::Continue(count - 1)) } else { Err(e)