fix broken multi-threaded scan_from_walkdir
i don't fully understand *why* this was broken but... it was
This commit is contained in:
parent
17a784732b
commit
c30aba35fd
1 changed files with 7 additions and 9 deletions
16
src/files.rs
16
src/files.rs
|
@ -151,17 +151,15 @@ pub fn scan_from_walkdir(
|
||||||
// split the entries into chunks of 32, and iterate over each chunk of entries in a separate thread
|
// split the entries into chunks of 32, and iterate over each chunk of entries in a separate thread
|
||||||
return entries
|
return entries
|
||||||
.par_chunks(CHUNKS)
|
.par_chunks(CHUNKS)
|
||||||
.map(|chunk| {
|
.flat_map_iter(|chunk| {
|
||||||
chunk
|
chunk
|
||||||
.iter() // iter over the chunk, which is a slice of DirEntry structs
|
.iter() // iter over the chunk, which is a slice of DirEntry structs
|
||||||
.partition_map::<Vec<_>, Vec<_>, _, _, _>(|entry| match scan_file(entry, canonical_paths) {
|
.map(|entry| scan_file(entry, canonical_paths))
|
||||||
Ok(f) => Either::Left(f),
|
.collect::<Vec<_>>() // TODO: is there a way to avoid having to collect here?
|
||||||
Err(e) => Either::Right(e)
|
}).partition_map(|result| match result {
|
||||||
}
|
Ok(f) => Either::Left(f),
|
||||||
)
|
Err(e) => Either::Right(e),
|
||||||
})
|
});
|
||||||
.flatten()
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// should always be false when multi-threading is disabled at compile time
|
// should always be false when multi-threading is disabled at compile time
|
||||||
|
|
Loading…
Reference in a new issue