fix(core): remove unwrap/expect in non-test code

- cache/lru.rs: replace lock().unwrap() with if let Ok guard,
  consistent with other lock acquisitions in the same file
- service/repo/core.rs: replace try_into().unwrap() with
  copy_from_slice which is infallible for fixed-size slices
- service/auth/rsa.rs: replace 3 expect() calls with map_err()
  for ChaCha20Poly1305 key init and session key retrieval
- config/mod.rs: replace GLOBAL_CONFIG.get().expect() with
  unwrap_or_else fallback to empty config
This commit is contained in:
zhenyi
2026-06-10 18:48:49 +08:00
parent d6c468a9fc
commit b83a842c6f
4 changed files with 155 additions and 46 deletions
+14 -14
View File
@@ -174,22 +174,22 @@ impl<K: Eq + Hash + Clone, V: Clone> LruTtlCache<K, V> {
return;
}
let mut lru = self.lru.lock().unwrap();
if let Ok(mut lru) = self.lru.lock() {
if lru.len() >= self.capacity
&& let Some(evicted_key) = lru.pop_back()
{
self.map.remove(&evicted_key);
}
if lru.len() >= self.capacity
&& let Some(evicted_key) = lru.pop_back()
{
self.map.remove(&evicted_key);
self.map.insert(
key.clone(),
CacheEntry {
value,
expires_at: now + ttl,
},
);
lru.push_front(key);
}
self.map.insert(
key.clone(),
CacheEntry {
value,
expires_at: now + ttl,
},
);
lru.push_front(key);
}
pub fn remove(&self, key: &K) -> Option<V> {