fix broken multi-threaded scan_from_walkdir

i don't fully understand *why* this was broken but... it was
This commit is contained in:
Lynne Megido 2021-10-05 01:45:18 +10:00
parent 17a784732b
commit c30aba35fd
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90

View File

@ -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