Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
perf: remove extra check for update since assigning returns the old v…
Browse files Browse the repository at this point in the history
…alue
  • Loading branch information
tippfehlr committed Feb 25, 2024
1 parent 5cad92e commit 57474f7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@ async fn webhook(path: web::Path<(String, String)>, state: web::Data<State>) ->
let (project, service) = path.into_inner();
let path = Path::new("/compose/").join(&project);

if state
if let Some(prev_value) = state
.currently_updating
.lock()
.unwrap()
.contains_key(&service)
.insert(format!("{}/{}", &project, &service), true)
{
eprintln!("Already updating {}/{}", &project, &service);
return HttpResponse::Conflict();
if prev_value {
eprintln!("Already updating {}/{}", &project, &service);
return HttpResponse::Conflict();
}
}

state
.currently_updating
.lock()
.unwrap()
.insert(format!("{}/{}", &project, &service), true);

let set_updating_false = || {
state
.currently_updating
Expand Down

0 comments on commit 57474f7

Please sign in to comment.