From 7346f1d5b79cc12e957498b3f7158e595369a868 Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Thu, 12 Mar 2026 22:29:47 +0100 Subject: [PATCH] =?UTF-8?q?fix(parsers):=20fallback=20CBR=20pour=20les=20.?= =?UTF-8?q?cbz=20qui=20sont=20en=20r=C3=A9alit=C3=A9=20des=20archives=20RA?= =?UTF-8?q?R?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Symétrique au fallback CBZ→RAR déjà existant dans analyze_cbr. Détecte les fichiers .cbz avec magic bytes RAR et les traite via le parser unrar. Co-Authored-By: Claude Sonnet 4.6 --- crates/parsers/src/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/parsers/src/lib.rs b/crates/parsers/src/lib.rs index 0394856..801d584 100644 --- a/crates/parsers/src/lib.rs +++ b/crates/parsers/src/lib.rs @@ -161,7 +161,20 @@ pub fn analyze_book(path: &Path, format: BookFormat, pdf_render_scale: u32) -> R fn analyze_cbz(path: &Path) -> Result<(i32, Vec)> { let file = std::fs::File::open(path) .with_context(|| format!("cannot open cbz: {}", path.display()))?; - let mut archive = zip::ZipArchive::new(file).context("invalid cbz archive")?; + let mut archive = match zip::ZipArchive::new(file) { + Ok(a) => a, + Err(e) => { + // Some .cbz files are actually RAR archives with the wrong extension — fallback to CBR parser + return analyze_cbr(path).map_err(|rar_err| { + anyhow::anyhow!( + "invalid cbz archive and RAR fallback also failed for {}: ZIP={}, RAR={}", + path.display(), + e, + rar_err + ) + }); + } + }; let mut image_names: Vec = Vec::new(); for i in 0..archive.len() {