Browse Source

fix broken multi-threaded scan_from_walkdir

i don't fully understand *why* this was broken but... it was
master
Lynne Megido 2 months ago
parent
commit
c30aba35fd
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
  1. 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…
Cancel
Save