diff --git a/src/background_jobs.rs b/src/background_jobs.rs index 77dc873307..a6e6190eac 100644 --- a/src/background_jobs.rs +++ b/src/background_jobs.rs @@ -317,7 +317,7 @@ pub struct RenderAndUploadReadmeJob { } pub struct Environment { - index: Arc>, + index: Mutex, http_client: AssertUnwindSafe, cloudfront: Option, fastly: Option, @@ -331,25 +331,9 @@ impl Environment { cloudfront: Option, fastly: Option, storage: Arc, - ) -> Self { - Self::new_shared( - Arc::new(Mutex::new(index)), - http_client, - cloudfront, - fastly, - storage, - ) - } - - pub fn new_shared( - index: Arc>, - http_client: Client, - cloudfront: Option, - fastly: Option, - storage: Arc, ) -> Self { Self { - index, + index: Mutex::new(index), http_client: AssertUnwindSafe(http_client), cloudfront, fastly, diff --git a/src/bin/background-worker.rs b/src/bin/background-worker.rs index 364b95c4f2..25c6f3b4eb 100644 --- a/src/bin/background-worker.rs +++ b/src/bin/background-worker.rs @@ -25,7 +25,7 @@ use diesel::r2d2; use diesel::r2d2::ConnectionManager; use reqwest::blocking::Client; use secrecy::ExposeSecret; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; use std::thread::sleep; use std::time::{Duration, Instant}; @@ -66,9 +66,7 @@ fn main() { let clone_start = Instant::now(); let repository_config = RepositoryConfig::from_environment(); - let repository = Arc::new(Mutex::new( - Repository::open(&repository_config).expect("Failed to clone index"), - )); + let repository = Repository::open(&repository_config).expect("Failed to clone index"); let clone_duration = clone_start.elapsed(); info!(duration = ?clone_duration, "Index cloned"); @@ -82,7 +80,7 @@ fn main() { .build() .expect("Couldn't build client"); - let environment = Environment::new_shared(repository, client, cloudfront, fastly, storage); + let environment = Environment::new(repository, client, cloudfront, fastly, storage); let environment = Arc::new(Some(environment));