diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 6b7c4a2115..768d0247e8 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -143,7 +143,8 @@ future<> sstable::rename_new_sstable_component_file(sstring from_name, sstring t future sstable::filesystem_storage::open_component(const sstable& sst, component_type type, open_flags flags, file_open_options options, bool check_integrity) { auto create_flags = open_flags::create | open_flags::exclusive; auto readonly = (flags & create_flags) != create_flags; - auto name = !readonly && temp_dir ? sst.temp_filename(type) : sst.filename(type); + auto tgt_dir = !readonly && temp_dir ? dir + "/" + sstable::sst_dir_basename(sst._generation) : dir; + auto name = sst.filename(tgt_dir, type); auto f = open_sstable_component_file_non_checked(name, flags, options, check_integrity); diff --git a/sstables/sstables.hh b/sstables/sstables.hh index b3ade596f3..67a5b8d408 100644 --- a/sstables/sstables.hh +++ b/sstables/sstables.hh @@ -367,10 +367,6 @@ public: return fmt::format("{}.sstable", gen); } - static sstring temp_sst_dir(const sstring& dir, generation_type gen) { - return dir + "/" + sst_dir_basename(gen); - } - static bool is_temp_dir(const fs::path& dirpath) { return dirpath.extension().string() == ".sstable"; @@ -507,10 +503,6 @@ private: return _storage.dir; } - sstring temp_filename(component_type f) const { - return filename(temp_sst_dir(_storage.dir, _generation), f); - } - size_t sstable_buffer_size; static std::unordered_map> _version_string; diff --git a/test/boost/database_test.cc b/test/boost/database_test.cc index 7c28fdd72a..830ba45706 100644 --- a/test/boost/database_test.cc +++ b/test/boost/database_test.cc @@ -307,12 +307,13 @@ SEASTAR_THREAD_TEST_CASE(test_distributed_loader_with_incomplete_sstables) { require_exist(file_name, true); }; - auto temp_sst_dir = sst::temp_sst_dir(sst_dir, generation_from_value(2)); - touch_dir(temp_sst_dir); + auto temp_sst_dir_2 = sst_dir + "/" + sst::sst_dir_basename(generation_from_value(2)); + touch_dir(temp_sst_dir_2); - temp_sst_dir = sst::temp_sst_dir(sst_dir, generation_from_value(3)); - touch_dir(temp_sst_dir); - auto temp_file_name = sst::filename(temp_sst_dir, ks, cf, sst::version_types::mc, generation_from_value(3), sst::format_types::big, component_type::TemporaryTOC); + auto temp_sst_dir_3 = sst_dir + "/" + sst::sst_dir_basename(generation_from_value(3)); + touch_dir(temp_sst_dir_3); + + auto temp_file_name = sst::filename(temp_sst_dir_3, ks, cf, sst::version_types::mc, generation_from_value(3), sst::format_types::big, component_type::TemporaryTOC); touch_file(temp_file_name); temp_file_name = sst::filename(sst_dir, ks, cf, sst::version_types::mc, generation_from_value(4), sst::format_types::big, component_type::TemporaryTOC); @@ -320,9 +321,9 @@ SEASTAR_THREAD_TEST_CASE(test_distributed_loader_with_incomplete_sstables) { temp_file_name = sst::filename(sst_dir, ks, cf, sst::version_types::mc, generation_from_value(4), sst::format_types::big, component_type::Data); touch_file(temp_file_name); - do_with_cql_env_thread([&sst_dir, &ks, &cf, &require_exist] (cql_test_env& e) { - require_exist(sst::temp_sst_dir(sst_dir, generation_from_value(2)), false); - require_exist(sst::temp_sst_dir(sst_dir, generation_from_value(3)), false); + do_with_cql_env_thread([&sst_dir, &ks, &cf, &require_exist, &temp_sst_dir_2, &temp_sst_dir_3] (cql_test_env& e) { + require_exist(temp_sst_dir_2, false); + require_exist(temp_sst_dir_3, false); require_exist(sst::filename(sst_dir, ks, cf, sst::version_types::mc, generation_from_value(4), sst::format_types::big, component_type::TemporaryTOC), false); require_exist(sst::filename(sst_dir, ks, cf, sst::version_types::mc, generation_from_value(4), sst::format_types::big, component_type::Data), false);