Fin de la correction de l'implémentation par ChatGPT.

This commit is contained in:
2025-11-16 08:34:33 +01:00
parent c81a4651d6
commit 66416dafa8
20 changed files with 567 additions and 131 deletions

View File

@@ -77,3 +77,17 @@ pub fn new_cache(dir: &str, limit: usize) -> Result<Cache> {
let transformer_factory = Arc::new(|| create_webp_transformer());
Cache::with_transformer(dir, limit, Some(transformer_factory))
}
/// Crée un cache de couvertures et lance une consolidation en arrière-plan.
pub async fn new_cache_with_consolidation(dir: &str, limit: usize) -> Result<Arc<Cache>> {
let cache = Arc::new(new_cache(dir, limit)?);
let cache_clone = cache.clone();
tokio::spawn(async move {
if let Err(e) = cache_clone.consolidate().await {
tracing::warn!("Failed to consolidate cover cache on startup: {}", e);
} else {
tracing::info!("Cover cache consolidated successfully on startup");
}
});
Ok(cache)
}

View File

@@ -60,7 +60,7 @@ pub mod openapi;
#[cfg(feature = "pmoconfig")]
pub mod config_ext;
pub use cache::{new_cache, Cache, CoversConfig};
pub use cache::{new_cache, new_cache_with_consolidation, Cache, CoversConfig};
#[cfg(feature = "pmoserver")]
pub use openapi::ApiDoc;