Skip to content

Commit 6b6e319

Browse files
committed
filter file_search to only search files
1 parent aab9ea3 commit 6b6e319

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"]
2727
[dependencies]
2828
iced = { git = "https://github.com/iced-rs/iced", features = ["advanced", "tokio", "image"], rev= "8bfd099c5929d927a3fdde666d4c645d0bd83cb7" }
2929
shared-mime-info = { git = "https://github.com/Kn4ughty/shared-mime-info" }
30+
# shared-mime-info = { path = "../shared-mime-info" } # This is useful for rapid testing
3031
anyhow = "1.0.99"
3132
libc = "0.2.175"
3233
log = "0.4.28"

benches/get_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
99
c.bench_function("get_files", |b| {
1010
b.iter(|| {
1111
//fo
12-
files::FileSearcher::find_files();
12+
files::FileSearcher::find_files()
1313
})
1414
});
1515
}

src/files/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ impl FileSearcher {
182182
)
183183
.into_iter()
184184
.filter_map(|e| e.ok())
185+
.filter(|e| !e.file_type().is_dir())
185186
{
186187
tx.try_send(Self::get_data(entry)).expect("Can send");
187188

@@ -194,7 +195,10 @@ impl FileSearcher {
194195
}
195196

196197
#[allow(dead_code)] // used in benchmarking
197-
pub fn find_files() {
198+
pub fn find_files() -> mpsc::Receiver<(PathBuf, Option<image::Handle>)> {
199+
let (mut tx, rx) = mpsc::channel(900000);
200+
let start = std::time::Instant::now();
201+
let mut count = 0;
198202
for dir in &config::SETTINGS
199203
.lock()
200204
.expect("mutex")
@@ -207,9 +211,13 @@ impl FileSearcher {
207211
.into_iter()
208212
.filter_map(|e| e.ok())
209213
{
210-
Self::get_data(entry);
214+
tx.try_send(Self::get_data(entry)).expect("Can send");
215+
216+
count += 1;
211217
}
212218
}
219+
log::info!("Time to **Send** {count} files: {:#?}", start.elapsed());
220+
rx
213221
}
214222

215223
fn run_at_index(&self, i: usize) {

0 commit comments

Comments
 (0)