From 5e2fb62f4fd8079d28be8864bdde9e9fcf33fac3 Mon Sep 17 00:00:00 2001 From: bepvte <8226605+bepvte@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:44:01 -0500 Subject: [PATCH] fix --- Cargo.toml | 10 ++++++++-- src/index.rs | 17 ++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 158b4cc..58b7802 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,10 +22,16 @@ rayon = "1.8.1" rusqlite = { version = "0.30.0", features = ["bundled"] } walkdir = "2.4.0" glob = "0.3.1" -image = { version = "0.24.8", default-features = false, features = ["webp", "png", "jpeg", "bmp", "gif"] } +image = { version = "0.24.8", features = ["webp", "png", "jpeg", "bmp", "gif"], default-features = false } tikv-jemallocator = { version = "0.5.4", features = ["unprefixed_malloc_on_supported_platforms"] } leptonica-plumbing = { version = "1.3.0", path = "libs/leptonica-plumbing" } -leptess = { version = "0.15.0", path = "libs/leptess" } +leptess = { version = "0.15.0", path = "libs/leptess", default-features = false } [workspace] members = ["libs/*"] + +[profile.release] +opt-level = 3 +strip = false +debug = 1 # for perf analysis +lto = "thin" diff --git a/src/index.rs b/src/index.rs index 1f6abd4..5cb449e 100644 --- a/src/index.rs +++ b/src/index.rs @@ -103,11 +103,11 @@ pub fn index_dir(db: &mut DB, path: &Path, options: IndexOptions) -> Result<()> let abar = arcbar.clone(); let chunk: Vec<_> = chunk .into_iter() - .filter_map(|p| { + .filter(|p| { if !options.rescan && db.is_indexed(&p.0, &p.1) { db.unmark_file(&p.0); abar.lock().unwrap().update(1).unwrap(); - return None; + return false; } if let Some((max_width, max_height)) = options.max_dimensions { let img = ImageReader::open(&p.0) @@ -116,12 +116,15 @@ pub fn index_dir(db: &mut DB, path: &Path, options: IndexOptions) -> Result<()> match img { Err(_) => { eprintln!("Failed to read image to check dimensions: {:?}", p.0); - return None; + return false; } Ok(img) => match img.into_dimensions() { Err(e) => { - eprintln!("Failed to decode image dimensions: {}", e); - return None; + eprintln!( + "Failed to decode image dimensions: {} Skipping: {:?}", + e, p.0 + ); + return false; } Ok((width, height)) => { if width > max_width || height > max_height { @@ -131,13 +134,13 @@ pub fn index_dir(db: &mut DB, path: &Path, options: IndexOptions) -> Result<()> p.0, width, height ); } - return None; + return false; } } }, }; } - return Some(p); + return true; }) .collect();