diff --git a/sstables/sstable_directory.cc b/sstables/sstable_directory.cc index 430bc02447..916752f84f 100644 --- a/sstables/sstable_directory.cc +++ b/sstables/sstable_directory.cc @@ -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)); }); diff --git a/sstables/sstable_directory.hh b/sstables/sstable_directory.hh index 7094d2044d..263671b4e9 100644 --- a/sstables/sstable_directory.hh +++ b/sstables/sstable_directory.hh @@ -93,6 +93,7 @@ public: future<> close(); future<> process(sstable_directory& directory, fs::path location, process_flags flags); + future<> commit(); }; private: