correctness on search-server1

This commit is contained in:
Priec
2026-09-05 01:06:43 +02:00
parent 7ad5704776
commit daa292e230
3 changed files with 12 additions and 17 deletions

View File

@@ -160,12 +160,16 @@ impl SearcherService {
}
}
pub fn invalidate_profile(&self, profile_name: &str) -> Result<(), Status> {
self.profiles
pub fn replace_profile_index(
&self,
profile_name: &str,
replace: impl FnOnce() -> anyhow::Result<()>,
) -> anyhow::Result<()> {
let mut profiles = self.profiles
.lock()
.map_err(|_| Status::internal("Profile index cache lock poisoned"))?
.remove(profile_name);
Ok(())
.map_err(|_| anyhow::anyhow!("Profile index cache lock poisoned"))?;
profiles.remove(profile_name);
replace()
}
async fn run_rpc(
@@ -721,22 +725,13 @@ fn profile_index(
profile_name: &str,
path: &Path,
) -> Result<Arc<ProfileIndex>, Status> {
{
let cache_guard = cache
.lock()
.map_err(|_| Status::internal("Profile index cache lock poisoned"))?;
if let Some(index) = cache_guard.get(profile_name) {
return Ok(index.clone());
}
}
let opened = Arc::new(ProfileIndex::open(path)?);
let mut cache_guard = cache
.lock()
.map_err(|_| Status::internal("Profile index cache lock poisoned"))?;
if let Some(index) = cache_guard.get(profile_name) {
return Ok(index.clone());
}
let opened = Arc::new(ProfileIndex::open(path)?);
cache_guard.insert(profile_name.to_string(), opened.clone());
Ok(opened)
}

2
server

Submodule server updated: 5455e7cb3a...2cf38b6882