sstable_directory: Move most of .commit_directory_changes() on lister

Committing any changes made while scanning the storage is
storage-specific. Just like .process() was moved on lister, the
.commit() now does the same.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2023-02-13 19:11:14 +03:00
parent 70d6bfc109
commit e6941d0baa
2 changed files with 7 additions and 5 deletions

View File

@@ -248,12 +248,13 @@ future<> sstable_directory::components_lister::process(sstable_directory& direct
}
}
future<>
sstable_directory::commit_directory_changes() {
auto files_for_removal = std::exchange(_lister->_state->files_for_removal, {});
_lister.reset();
future<> sstable_directory::commit_directory_changes() {
return _lister->commit().finally([x = std::move(_lister)] {});
}
future<> sstable_directory::components_lister::commit() {
// Remove all files scheduled for removal
return parallel_for_each(std::move(files_for_removal), [] (sstring path) {
return parallel_for_each(std::exchange(_state->files_for_removal, {}), [] (sstring path) {
dirlog.info("Removing file {}", path);
return remove_file(std::move(path));
});

View File

@@ -93,6 +93,7 @@ public:
future<> close();
future<> process(sstable_directory& directory, fs::path location, process_flags flags);
future<> commit();
};
private: