Commitlog: do more extensive dir entry probes to determine type

Since directory_entry "type" might not be set.
Ensuring that code does not remain future free or easy to read.

Fixes #157.
This commit is contained in:
Calle Wilund
2015-08-17 15:53:45 +02:00
committed by Avi Kivity
parent 932ddc328c
commit 8f0f4e7945
2 changed files with 43 additions and 23 deletions

View File

@@ -167,11 +167,19 @@ public:
}
future<> process(directory_entry de) {
if (de.type && de.type == directory_entry_type::regular) {
descriptor d(de.name);
_ids = std::max(_ids, d.id);
}
return make_ready_future<>();
auto entry_type = [this](const directory_entry & de) {
if (!de.type && !de.name.empty()) {
return engine().file_type(cfg.commit_log_location + "/" + de.name);
}
return make_ready_future<std::experimental::optional<directory_entry_type>>(de.type);
};
return entry_type(de).then([de, this](auto type) {
if (type == directory_entry_type::regular) {
descriptor d(de.name);
_ids = std::max(_ids, d.id);
}
return make_ready_future<>();
});
}
future<> init();