Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bepvte committed Jan 30, 2024
1 parent 346320b commit 5e2fb62
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 10 additions & 7 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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();

Expand Down

0 comments on commit 5e2fb62

Please sign in to comment.