mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-14 14:59:52 -04:00
Cleanup scanner
This commit is contained in:
parent
85b1ca1a85
commit
bd70ec7d7a
@ -243,6 +243,9 @@ class scanner_ : public scanner::impl {
|
|||||||
void scan(filesystem_writer& fsw, const std::string& path, progress& prog);
|
void scan(filesystem_writer& fsw, const std::string& path, progress& prog);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::shared_ptr<entry> scan_tree(const std::string& path, progress& prog);
|
||||||
|
void order_files(inode_manager& im);
|
||||||
|
|
||||||
const block_manager::config& cfg_;
|
const block_manager::config& cfg_;
|
||||||
const scanner_options& options_;
|
const scanner_options& options_;
|
||||||
std::shared_ptr<entry_factory> entry_;
|
std::shared_ptr<entry_factory> entry_;
|
||||||
@ -270,12 +273,8 @@ scanner_<LoggerPolicy>::scanner_(logger& lgr, worker_group& wg,
|
|||||||
, log_(lgr) {}
|
, log_(lgr) {}
|
||||||
|
|
||||||
template <typename LoggerPolicy>
|
template <typename LoggerPolicy>
|
||||||
void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
std::shared_ptr<entry>
|
||||||
const std::string& path, progress& prog) {
|
scanner_<LoggerPolicy>::scan_tree(const std::string& path, progress& prog) {
|
||||||
log_.info() << "scanning " << path;
|
|
||||||
|
|
||||||
prog.set_status_function(status_string);
|
|
||||||
|
|
||||||
auto root = entry_->create(*os_, path);
|
auto root = entry_->create(*os_, path);
|
||||||
|
|
||||||
if (root->type() != entry::E_DIR) {
|
if (root->type() != entry::E_DIR) {
|
||||||
@ -367,6 +366,48 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename LoggerPolicy>
|
||||||
|
void scanner_<LoggerPolicy>::order_files(inode_manager& im) {
|
||||||
|
switch (options_.file_order) {
|
||||||
|
case file_order_mode::NONE:
|
||||||
|
log_.info() << "keeping inode order";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case file_order_mode::PATH: {
|
||||||
|
log_.info() << "ordering " << im.count() << " inodes by path name...";
|
||||||
|
auto ti = log_.timed_info();
|
||||||
|
im.order_inodes();
|
||||||
|
ti << im.count() << " inodes ordered";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case file_order_mode::SCRIPT:
|
||||||
|
log_.info() << "ordering " << im.count() << " inodes using script...";
|
||||||
|
im.order_inodes(script_);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case file_order_mode::SIMILARITY: {
|
||||||
|
log_.info() << "ordering " << im.count() << " inodes by similarity...";
|
||||||
|
auto ti = log_.timed_info();
|
||||||
|
im.order_inodes_by_similarity();
|
||||||
|
ti << im.count() << " inodes ordered";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename LoggerPolicy>
|
||||||
|
void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
||||||
|
const std::string& path, progress& prog) {
|
||||||
|
log_.info() << "scanning " << path;
|
||||||
|
|
||||||
|
prog.set_status_function(status_string);
|
||||||
|
|
||||||
|
auto root = scan_tree(path, prog);
|
||||||
|
|
||||||
// now scan all files
|
// now scan all files
|
||||||
scan_files_visitor sfv(wg_, *os_, prog);
|
scan_files_visitor sfv(wg_, *os_, prog);
|
||||||
root->accept(sfv);
|
root->accept(sfv);
|
||||||
@ -374,9 +415,6 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
|||||||
log_.info() << "waiting for background scanners...";
|
log_.info() << "waiting for background scanners...";
|
||||||
wg_.wait();
|
wg_.wait();
|
||||||
|
|
||||||
std::unordered_map<std::string_view, std::vector<file*>, folly::Hash>
|
|
||||||
file_hash;
|
|
||||||
|
|
||||||
log_.info() << "assigning directory and link inodes...";
|
log_.info() << "assigning directory and link inodes...";
|
||||||
|
|
||||||
uint32_t first_link_inode = 0;
|
uint32_t first_link_inode = 0;
|
||||||
@ -401,32 +439,7 @@ void scanner_<LoggerPolicy>::scan(filesystem_writer& fsw,
|
|||||||
<< prog.duplicate_files << "/" << prog.files_found
|
<< prog.duplicate_files << "/" << prog.files_found
|
||||||
<< " duplicate files";
|
<< " duplicate files";
|
||||||
|
|
||||||
switch (options_.file_order) {
|
order_files(*im);
|
||||||
case file_order_mode::NONE:
|
|
||||||
log_.info() << "keeping inode order";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case file_order_mode::PATH: {
|
|
||||||
log_.info() << "ordering " << im->count() << " inodes by path name...";
|
|
||||||
auto ti = log_.timed_info();
|
|
||||||
im->order_inodes();
|
|
||||||
ti << im->count() << " inodes ordered";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case file_order_mode::SCRIPT:
|
|
||||||
log_.info() << "ordering " << im->count() << " inodes using script...";
|
|
||||||
im->order_inodes(script_);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case file_order_mode::SIMILARITY: {
|
|
||||||
log_.info() << "ordering " << im->count() << " inodes by similarity...";
|
|
||||||
auto ti = log_.timed_info();
|
|
||||||
im->order_inodes_by_similarity();
|
|
||||||
ti << im->count() << " inodes ordered";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log_.info() << "assigning file inodes...";
|
log_.info() << "assigning file inodes...";
|
||||||
im->number_inodes(first_file_inode);
|
im->number_inodes(first_file_inode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user