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
|
||||
return entries
|
||||
.par_chunks(CHUNKS)
|
||||
.map(|chunk| {
|
||||
.flat_map_iter(|chunk| {
|
||||
chunk
|
||||
.iter() // iter over the chunk, which is a slice of DirEntry structs
|
||||
.partition_map::<Vec<_>, Vec<_>, _, _, _>(|entry| match scan_file(entry, canonical_paths) {
|
||||
Ok(f) => Either::Left(f),
|
||||
Err(e) => Either::Right(e)
|
||||
}
|
||||
)
|
||||
})
|
||||
.flatten()
|
||||
.collect()
|
||||
.map(|entry| scan_file(entry, canonical_paths))
|
||||
.collect::<Vec<_>>() // TODO: is there a way to avoid having to collect here?
|
||||
}).partition_map(|result| match result {
|
||||
Ok(f) => Either::Left(f),
|
||||
Err(e) => Either::Right(e),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// should always be false when multi-threading is disabled at compile time
|
||||
|
|
Loading…
Reference in a new issue