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