refactor: Phase A — extraction des helpers partagés et micro-fixes

- Centralise remap_libraries_path/unmap_libraries_path dans crates/core/paths.rs
  (supprime 4 copies dupliquées dans API + indexer)
- Centralise mode_to_interval_minutes/validate_schedule_mode dans crates/core/schedule.rs
  (remplace 8 match blocks + 4 validations inline)
- Ajoute helpers env_or<T>/env_string_or dans config.rs, utilise ThumbnailConfig::default()
  comme base dans from_env() (élimine la duplication des valeurs par défaut)
- Supprime std::mem::take inutile dans books.rs
- Cible #[allow(dead_code)] sur le champ plutôt que le struct (metadata.rs)
- Remplace eprintln! par tracing::warn! dans parsers
- Fix clippy boolean logic bug dans prowlarr.rs

10 nouveaux tests unitaires (paths + schedule)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 11:54:03 +02:00
parent 776ef679c2
commit 38a0f56328
13 changed files with 206 additions and 159 deletions

View File

@@ -262,7 +262,7 @@ pub async fn list_books(
)?;
let total: i64 = count_row.get(0);
let mut items: Vec<BookItem> = rows
let items: Vec<BookItem> = rows
.iter()
.map(|row| {
let thumbnail_path: Option<String> = row.get("thumbnail_path");
@@ -288,7 +288,7 @@ pub async fn list_books(
.collect();
Ok(Json(BooksPage {
items: std::mem::take(&mut items),
items,
total,
page,
limit,
@@ -369,23 +369,8 @@ pub async fn get_book(
// ─── Helpers ──────────────────────────────────────────────────────────────────
pub(crate) fn remap_libraries_path(path: &str) -> String {
if let Ok(root) = std::env::var("LIBRARIES_ROOT_PATH") {
if path.starts_with("/libraries/") {
return path.replacen("/libraries", &root, 1);
}
}
path.to_string()
}
fn unmap_libraries_path(path: &str) -> String {
if let Ok(root) = std::env::var("LIBRARIES_ROOT_PATH") {
if path.starts_with(&root) {
return path.replacen(&root, "/libraries", 1);
}
}
path.to_string()
}
pub(crate) use stripstream_core::paths::remap_libraries_path;
pub(crate) use stripstream_core::paths::unmap_libraries_path;
// ─── Convert CBR → CBZ ───────────────────────────────────────────────────────