Merge branch 'development' of https://git.fifthgrid.com/blockstorage/repertory into development
All checks were successful
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-02-05 07:21:45 -06:00
commit 31c5b6f1db
2 changed files with 59 additions and 49 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
#
NUM_JOBS=${MY_NUM_JOBS}
if [[ -z "${NUM_JOBS}" ]]; then
NUM_JOBS=$(getconf _NPROCESSORS_ONLN 2> /dev/null || getconf NPROCESSORS_ONLN 2> /dev/null || echo 1)

View File

@ -1037,8 +1037,13 @@ void file_manager::upload_handler() {
constexpr const auto *function_name = static_cast<const char *>(__FUNCTION__);
while (not stop_requested_) {
auto should_wait{true};
unique_mutex_lock upload_lock(upload_mtx_);
if (not stop_requested_) {
if (stop_requested_) {
upload_notify_.notify_all();
continue;
}
if (upload_lookup_.size() < config_.get_max_upload_count()) {
auto result = db::db_select{*db_.get(), upload_table}
.order_by("api_path", true)
@ -1047,8 +1052,7 @@ void file_manager::upload_handler() {
try {
std::optional<db::db_select::row> row;
if (result.get_row(row) && row.has_value()) {
auto api_path =
row->get_column("api_path").get_value<std::string>();
auto api_path = row->get_column("api_path").get_value<std::string>();
auto source_path =
row->get_column("source_path").get_value<std::string>();
@ -1056,12 +1060,16 @@ void file_manager::upload_handler() {
auto res = provider_.get_filesystem_item(api_path, false, fsi);
switch (res) {
case api_error::item_not_found: {
event_system::instance().raise<file_upload_not_found>(
api_path, source_path);
should_wait = false;
//
event_system::instance().raise<file_upload_not_found>(api_path,
source_path);
remove_upload(api_path, true);
} break;
case api_error::success: {
should_wait = false;
upload_lookup_[fsi.api_path] =
std::make_unique<upload>(fsi, provider_);
auto del_res = db::db_select{*db_.get(), upload_table}
@ -1083,10 +1091,9 @@ void file_manager::upload_handler() {
} break;
default: {
event_system::instance().raise<file_upload_retry>(
api_path, source_path, res);
event_system::instance().raise<file_upload_retry>(api_path,
source_path, res);
queue_upload(api_path, source_path, true);
upload_notify_.wait_for(upload_lock, 5s);
} break;
}
}
@ -1094,6 +1101,9 @@ void file_manager::upload_handler() {
utils::error::raise_error(function_name, ex, "query error");
}
}
if (should_wait) {
upload_notify_.wait_for(upload_lock, 5s);
}
upload_notify_.notify_all();