Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Jul 31, 2024
1 parent 4b85a9f commit 6408259
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
22 changes: 9 additions & 13 deletions src/api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/api/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +27,7 @@ pub fn delta_upload(
config: Data<Config>,
) -> impl Future<Item = HttpResponse, Error = ApiError> {
futures::done(req.has_token_claims("delta", ClaimsScope::Generate))
.and_then(move |_| futures::done(config.get_repoconfig(&params.repo).map(|rc| rc.clone())))
.and_then(move |_| futures::done(config.get_repoconfig(&params.repo).cloned()))
.and_then(move |repoconfig| {
let uploadstate = Arc::new(UploadState {
only_deltas: true,
Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn load_config<P: AsRef<Path>>(path: P) -> io::Result<Config> {
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)?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/jobs/publish_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!({
Expand Down
12 changes: 6 additions & 6 deletions src/ostree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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(),
));
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6408259

Please sign in to comment.