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
+3 -2
View File
@@ -49,6 +49,7 @@ impl AppConfig {
}
pub fn load() -> AppConfig {
dotenvy::dotenv().ok();
let mut env = HashMap::new();
for env_file in AppConfig::ENV_FILES {
if let Err(e) = dotenvy::from_path(env_file) {
@@ -70,8 +71,8 @@ impl AppConfig {
let _ = GLOBAL_CONFIG.set(this);
GLOBAL_CONFIG
.get()
.expect("global config should be set after load")
.clone()
.cloned()
.unwrap_or_else(|| AppConfig { env: HashMap::new() })
}
}
}