diff --git a/src/main.rs b/src/main.rs index 10e3c03..cc86e0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::{ net::SocketAddr, process, - sync::{Arc, Mutex}, + sync::{Arc, Mutex, RwLock}, time::Duration, }; @@ -19,7 +19,7 @@ mod routes; mod util; lazy_static! { - pub static ref REVISIONS: Mutex> = Mutex::new(vec![]); + pub static ref REVISIONS: RwLock> = RwLock::new(vec![]); } #[allow(dead_code)] diff --git a/src/routes.rs b/src/routes.rs index c0a8b06..779f440 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -26,7 +26,7 @@ pub async fn get_revisions( return Err(RATE_LIMIT.into_response()); } - let folders = match REVISIONS.lock() { + let folders = match REVISIONS.read() { Ok(r) => r.clone(), Err(why) => { log::error!("Could not lock REVISIONS, {why}"); diff --git a/src/util.rs b/src/util.rs index 43fce8d..bbb03da 100644 --- a/src/util.rs +++ b/src/util.rs @@ -26,7 +26,7 @@ pub async fn explore_revisions() -> std::io::Result<()> { } } - let mut revisions = REVISIONS.lock().unwrap(); + let mut revisions = REVISIONS.write().unwrap(); *revisions = revisions_vec; Ok(())