Scan files after scanning directories has finished

Hopefully this will always be more efficient in terms of
disk access patterns.
This commit is contained in:
Marcus Holland-Moritz 2020-11-24 22:22:19 +01:00
parent ca0dfa3e53
commit 9788567c39

View File

@ -335,10 +335,6 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
case entry::E_FILE:
prog.files_found++;
wg_.add_job([=, this, &prog] {
pe->scan(*os_, prog);
prog.files_scanned++;
});
break;
case entry::E_LINK:
@ -374,6 +370,18 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
}
}
// now scan all files
// TODO: automatically adjust # of worker threads based on load
root->walk([&](entry* ep) {
wg_.add_job([=, this, &prog] {
if (ep->type() == entry::E_FILE) {
prog.current.store(ep);
ep->scan(*os_, prog);
prog.files_scanned++;
}
});
});
log_.info() << "waiting for background scanners...";
wg_.wait();