diff --git a/crates/forge-web-pages/src/pages/tree.rs b/crates/forge-web-pages/src/pages/tree.rs index 0eea46a..a42992c 100644 --- a/crates/forge-web-pages/src/pages/tree.rs +++ b/crates/forge-web-pages/src/pages/tree.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; -use std::sync::{Mutex, OnceLock}; use std::time::Duration; use forge_core::Repo as RepoRow; @@ -67,13 +66,6 @@ pub async fn read_file(path: PathBuf, commit: String, file: String) -> Result)>>; - -fn last_commit_cache() -> &'static LastCommitCache { - static CACHE: OnceLock = OnceLock::new(); - CACHE.get_or_init(|| Mutex::new(HashMap::new())) -} - pub async fn last_commits( state: &AppState, path: &Path, @@ -81,22 +73,9 @@ pub async fn last_commits( dir: &str, names: &[String], ) -> HashMap { - let key = (path.to_path_buf(), dir.to_owned()); - if let Some((at, map)) = last_commit_cache().lock().expect("last-commit cache").get(&key) - && at == commit - { - return map.clone(); - } let walk = history::last_commits(&state.git, path, commit, dir, names, LAST_COMMIT_WALK); match tokio::time::timeout(LAST_COMMIT_TIMEOUT, walk).await { - Ok(Ok(map)) => { - let mut cache = last_commit_cache().lock().expect("last-commit cache"); - if cache.len() >= 1024 { - cache.clear(); - } - cache.insert(key, (commit.to_owned(), map.clone())); - map - } + Ok(Ok(map)) => map, Ok(Err(e)) => { tracing::warn!(error = %e, "last-commit walk failed"); HashMap::new()