2 Commits

Author SHA1 Message Date
33e8e0890b test fixes
All checks were successful
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
2023-11-30 12:54:00 -06:00
e2e82edefb script changes 2023-11-30 10:52:11 -06:00
4 changed files with 39 additions and 22 deletions

View File

@@ -12,6 +12,8 @@ if [ -z "${BUILD_ARCH}" ]; then
BUILD_ARCH=64_bit BUILD_ARCH=64_bit
fi fi
ln -sf ${SOURCE_DIR}/build/compile_commands.json ${SOURCE_DIR}/compile_commands.json
docker stop repertory_${NAME} docker stop repertory_${NAME}
docker rm repertory_${NAME} docker rm repertory_${NAME}
docker build -t repertory:${NAME} - < ${SOURCE_DIR}/docker/${BUILD_ARCH}/${NAME} && docker build -t repertory:${NAME} - < ${SOURCE_DIR}/docker/${BUILD_ARCH}/${NAME} &&

View File

@@ -41,6 +41,15 @@ cmake ../.. ${CMAKE_ADDITIONAL_OPTS} \
-DREPERTORY_ENABLE_S3=ON \ -DREPERTORY_ENABLE_S3=ON \
-DREPERTORY_ENABLE_S3_TESTING=ON || exit 1 -DREPERTORY_ENABLE_S3_TESTING=ON || exit 1
pushd ..
ln -sf ${BUILD_FOLDER}/compile_commands.json .
ln -sf ${BUILD_FOLDER}/repertory${EXE_EXT} .
ln -sf ${BUILD_FOLDER}/unittests${EXE_EXT} .
if [ "${IS_MINGW}" == "1" ]; then
ln -sf ${BUILD_FOLDER}/winfsp-x64.dll .
fi
popd
if [ "${BUILD_CLEAN}" == "clean" ]; then if [ "${BUILD_CLEAN}" == "clean" ]; then
make clean make clean
fi fi

View File

@@ -109,45 +109,42 @@ void file_manager::close_all(const std::string &api_path) {
return; return;
} }
handles = iter->second->get_handles(); auto closeable_file = iter->second;
for (auto &handle : handles) { handles = closeable_file->get_handles();
open_file_lookup_[api_path]->remove(handle); for (auto handle : handles) {
closeable_file->remove(handle);
} }
auto file = open_file_lookup_.at(api_path);
open_file_lookup_.erase(api_path); open_file_lookup_.erase(api_path);
file_lock.unlock(); file_lock.unlock();
file->close(); closeable_file->close();
} }
void file_manager::close_timed_out_files() { void file_manager::close_timed_out_files() {
unique_recur_mutex_lock file_lock(open_file_mtx_); unique_recur_mutex_lock file_lock(open_file_mtx_);
auto closeable_list = std::accumulate( auto closeable_list =
open_file_lookup_.begin(), open_file_lookup_.end(), std::accumulate(open_file_lookup_.begin(), open_file_lookup_.end(),
std::vector<std::string>{}, [](auto items, const auto &item) -> auto { std::vector<std::shared_ptr<i_closeable_open_file>>{},
if (item.second->get_open_file_count() == 0U && [](auto items, const auto &item) -> auto {
item.second->can_close()) { if (item.second->get_open_file_count() == 0U &&
items.emplace_back(item.first); item.second->can_close()) {
} items.push_back(item.second);
return items; }
}); return items;
});
std::vector<std::shared_ptr<i_closeable_open_file>> open_files{}; for (const auto &closeable_file : closeable_list) {
for (const auto &api_path : closeable_list) { open_file_lookup_.erase(closeable_file->get_api_path());
auto closeable_file = open_file_lookup_.at(api_path);
open_file_lookup_.erase(api_path);
open_files.push_back(closeable_file);
} }
closeable_list.clear();
file_lock.unlock(); file_lock.unlock();
for (auto &closeable_file : open_files) { for (auto &closeable_file : closeable_list) {
closeable_file->close(); closeable_file->close();
event_system::instance().raise<download_timeout>( event_system::instance().raise<download_timeout>(
closeable_file->get_api_path()); closeable_file->get_api_path());
} }
closeable_list.clear();
} }
auto file_manager::create(const std::string &api_path, api_meta_map &meta, auto file_manager::create(const std::string &api_path, api_meta_map &meta,

View File

@@ -1315,6 +1315,9 @@ TEST(file_manager,
EXPECT_CALL(mp, set_item_meta("/test_open.txt", META_SOURCE, _)) EXPECT_CALL(mp, set_item_meta("/test_open.txt", META_SOURCE, _))
.WillOnce(Return(api_error::success)); .WillOnce(Return(api_error::success));
EXPECT_CALL(*non_writeable, has_handle(1)).WillOnce([]() -> bool {
return true;
});
EXPECT_TRUE(fm.get_open_file(handle, true, f)); EXPECT_TRUE(fm.get_open_file(handle, true, f));
EXPECT_NE(non_writeable.get(), f.get()); EXPECT_NE(non_writeable.get(), f.get());
EXPECT_EQ(std::size_t(1U), fm.get_open_file_count()); EXPECT_EQ(std::size_t(1U), fm.get_open_file_count());
@@ -1495,6 +1498,10 @@ TEST(file_manager, open_file_creates_source_path_if_empty) {
#else #else
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
#endif #endif
EXPECT_CALL(*of, has_handle(1)).Times(2).WillRepeatedly([]() -> bool {
return true;
});
EXPECT_TRUE(fm.get_open_file(1U, true, f)); EXPECT_TRUE(fm.get_open_file(1U, true, f));
EXPECT_EQ(std::size_t(1U), fm.get_open_file_count()); EXPECT_EQ(std::size_t(1U), fm.get_open_file_count());
EXPECT_TRUE(f); EXPECT_TRUE(f);
@@ -1546,6 +1553,8 @@ TEST(file_manager, open_file_first_file_handle_is_not_zero) {
#else #else
EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f)); EXPECT_EQ(api_error::success, fm.open(of, O_RDWR, handle, f));
#endif #endif
EXPECT_CALL(*of, has_handle(1)).WillOnce([]() -> bool { return true; });
EXPECT_TRUE(fm.get_open_file(1U, true, f)); EXPECT_TRUE(fm.get_open_file(1U, true, f));
EXPECT_GT(handle, std::uint64_t(0U)); EXPECT_GT(handle, std::uint64_t(0U));
} }