refactor event system
This commit is contained in:
@ -1379,10 +1379,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
~remote_server_base() override {
|
~remote_server_base() override {
|
||||||
event_system::instance().raise<service_stop_begin>("remote_server_base");
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
"remote_server_base");
|
||||||
client_pool_.shutdown();
|
client_pool_.shutdown();
|
||||||
packet_server_.reset();
|
packet_server_.reset();
|
||||||
event_system::instance().raise<service_stop_end>("remote_server_base");
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
"remote_server_base");
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -151,11 +151,14 @@ void client_pool::remove_client(const std::string &client_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void client_pool::shutdown() {
|
void client_pool::shutdown() {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (shutdown_) {
|
if (shutdown_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_begin>("client_pool");
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
"client_pool");
|
||||||
unique_mutex_lock pool_lock(pool_mutex_);
|
unique_mutex_lock pool_lock(pool_mutex_);
|
||||||
if (not shutdown_) {
|
if (not shutdown_) {
|
||||||
shutdown_ = true;
|
shutdown_ = true;
|
||||||
@ -165,6 +168,7 @@ void client_pool::shutdown() {
|
|||||||
pool_lookup_.clear();
|
pool_lookup_.clear();
|
||||||
}
|
}
|
||||||
pool_lock.unlock();
|
pool_lock.unlock();
|
||||||
event_system::instance().raise<service_stop_end>("client_pool");
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
"client_pool");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -46,7 +46,10 @@ packet_server::packet_server(std::uint16_t port, std::string token,
|
|||||||
}
|
}
|
||||||
|
|
||||||
packet_server::~packet_server() {
|
packet_server::~packet_server() {
|
||||||
event_system::instance().raise<service_stop_begin>("packet_server");
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
"packet_server");
|
||||||
std::thread([this]() {
|
std::thread([this]() {
|
||||||
for (std::size_t i = 0U; i < service_threads_.size(); i++) {
|
for (std::size_t i = 0U; i < service_threads_.size(); i++) {
|
||||||
io_context_.stop();
|
io_context_.stop();
|
||||||
@ -55,7 +58,8 @@ packet_server::~packet_server() {
|
|||||||
|
|
||||||
server_thread_->join();
|
server_thread_->join();
|
||||||
server_thread_.reset();
|
server_thread_.reset();
|
||||||
event_system::instance().raise<service_stop_end>("packet_server");
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
"packet_server");
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet_server::add_client(connection &conn, const std::string &client_id) {
|
void packet_server::add_client(connection &conn, const std::string &client_id) {
|
||||||
|
@ -59,7 +59,7 @@ file_manager::file_manager(app_config &config, i_provider &provider)
|
|||||||
}
|
}
|
||||||
|
|
||||||
E_SUBSCRIBE_EXACT(file_upload_completed,
|
E_SUBSCRIBE_EXACT(file_upload_completed,
|
||||||
[this](auto &&event) { this->upload_completed(event); });
|
[this](auto &&event) { this->upload_completed(event); });
|
||||||
}
|
}
|
||||||
|
|
||||||
file_manager::~file_manager() {
|
file_manager::~file_manager() {
|
||||||
@ -394,11 +394,10 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
|||||||
return open(api_path, directory, ofd, handle, file, nullptr);
|
return open(api_path, directory, ofd, handle, file, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto file_manager::open(const std::string &api_path, bool directory,
|
auto file_manager::open(
|
||||||
const open_file_data &ofd, std::uint64_t &handle,
|
const std::string &api_path, bool directory, const open_file_data &ofd,
|
||||||
std::shared_ptr<i_open_file> &file,
|
std::uint64_t &handle, std::shared_ptr<i_open_file> &file,
|
||||||
std::shared_ptr<i_closeable_open_file> closeable_file)
|
std::shared_ptr<i_closeable_open_file> closeable_file) -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto create_and_add_handle =
|
const auto create_and_add_handle =
|
||||||
@ -550,7 +549,7 @@ void file_manager::queue_upload(const std::string &api_path,
|
|||||||
})) {
|
})) {
|
||||||
remove_resume(api_path, source_path, true);
|
remove_resume(api_path, source_path, true);
|
||||||
event_system::instance().raise<file_upload_queued>(api_path, function_name,
|
event_system::instance().raise<file_upload_queued>(api_path, function_name,
|
||||||
source_path);
|
source_path);
|
||||||
} else {
|
} else {
|
||||||
event_system::instance().raise<file_upload_failed>(
|
event_system::instance().raise<file_upload_failed>(
|
||||||
api_path, "failed to queue upload", function_name, source_path);
|
api_path, "failed to queue upload", function_name, source_path);
|
||||||
@ -608,7 +607,7 @@ void file_manager::remove_resume(const std::string &api_path,
|
|||||||
|
|
||||||
if (mgr_db_->remove_resume(api_path)) {
|
if (mgr_db_->remove_resume(api_path)) {
|
||||||
event_system::instance().raise<download_resume_removed>(api_path,
|
event_system::instance().raise<download_resume_removed>(api_path,
|
||||||
source_path);
|
source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not no_lock) {
|
if (not no_lock) {
|
||||||
@ -685,7 +684,7 @@ void file_manager::remove_upload(const std::string &api_path, bool no_lock) {
|
|||||||
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
event_system::instance().raise<file_upload_removed>(api_path,
|
event_system::instance().raise<file_upload_removed>(api_path,
|
||||||
function_name);
|
function_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not no_lock) {
|
if (not no_lock) {
|
||||||
@ -770,8 +769,8 @@ auto file_manager::rename_directory(const std::string &from_api_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto file_manager::rename_file(const std::string &from_api_path,
|
auto file_manager::rename_file(const std::string &from_api_path,
|
||||||
const std::string &to_api_path, bool overwrite)
|
const std::string &to_api_path,
|
||||||
-> api_error {
|
bool overwrite) -> api_error {
|
||||||
if (not provider_.is_rename_supported()) {
|
if (not provider_.is_rename_supported()) {
|
||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
@ -913,7 +912,7 @@ void file_manager::start() {
|
|||||||
fsi, provider_, entry.read_state, *this);
|
fsi, provider_, entry.read_state, *this);
|
||||||
open_file_lookup_[entry.api_path] = closeable_file;
|
open_file_lookup_[entry.api_path] = closeable_file;
|
||||||
event_system::instance().raise<download_restored>(fsi.api_path,
|
event_system::instance().raise<download_restored>(fsi.api_path,
|
||||||
fsi.source_path);
|
fsi.source_path);
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
utils::error::raise_error(function_name, ex, "query error");
|
utils::error::raise_error(function_name, ex, "query error");
|
||||||
}
|
}
|
||||||
@ -924,11 +923,14 @@ void file_manager::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void file_manager::stop() {
|
void file_manager::stop() {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (stop_requested_) {
|
if (stop_requested_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_begin>("file_manager");
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
"file_manager");
|
||||||
|
|
||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
@ -962,7 +964,8 @@ void file_manager::stop() {
|
|||||||
|
|
||||||
upload_thread_.reset();
|
upload_thread_.reset();
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_end>("file_manager");
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
"file_manager");
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_manager::store_resume(const i_open_file &file) {
|
void file_manager::store_resume(const i_open_file &file) {
|
||||||
|
@ -45,10 +45,9 @@ namespace repertory {
|
|||||||
encrypt_provider::encrypt_provider(app_config &config)
|
encrypt_provider::encrypt_provider(app_config &config)
|
||||||
: config_(config), encrypt_config_(config.get_encrypt_config()) {}
|
: config_(config), encrypt_config_(config.get_encrypt_config()) {}
|
||||||
|
|
||||||
auto encrypt_provider::create_api_file(const std::string &api_path,
|
auto encrypt_provider::create_api_file(
|
||||||
bool directory,
|
const std::string &api_path, bool directory,
|
||||||
const std::string &source_path)
|
const std::string &source_path) -> api_file {
|
||||||
-> api_file {
|
|
||||||
auto times{utils::file::get_times(source_path)};
|
auto times{utils::file::get_times(source_path)};
|
||||||
if (not times.has_value()) {
|
if (not times.has_value()) {
|
||||||
throw std::runtime_error("failed to get file times");
|
throw std::runtime_error("failed to get file times");
|
||||||
@ -74,10 +73,10 @@ auto encrypt_provider::create_api_file(const std::string &api_path,
|
|||||||
void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory,
|
void encrypt_provider::create_item_meta(api_meta_map &meta, bool directory,
|
||||||
const api_file &file) {
|
const api_file &file) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
struct _stat64 buf{};
|
struct _stat64 buf {};
|
||||||
_stat64(file.source_path.c_str(), &buf);
|
_stat64(file.source_path.c_str(), &buf);
|
||||||
#else // !defined(_WIN32)
|
#else // !defined(_WIN32)
|
||||||
struct stat buf{};
|
struct stat buf {};
|
||||||
stat(file.source_path.c_str(), &buf);
|
stat(file.source_path.c_str(), &buf);
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
@ -157,9 +156,8 @@ auto encrypt_provider::do_fs_operation(
|
|||||||
return callback(cfg, source_path);
|
return callback(cfg, source_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encrypt_provider::get_api_path_from_source(const std::string &source_path,
|
auto encrypt_provider::get_api_path_from_source(
|
||||||
std::string &api_path) const
|
const std::string &source_path, std::string &api_path) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -199,9 +197,8 @@ auto encrypt_provider::get_directory_item_count(
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encrypt_provider::get_directory_items(const std::string &api_path,
|
auto encrypt_provider::get_directory_items(
|
||||||
directory_item_list &list) const
|
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
return do_fs_operation(
|
return do_fs_operation(
|
||||||
@ -334,9 +331,8 @@ auto encrypt_provider::get_file(const std::string &api_path,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encrypt_provider::get_file_list(api_file_list &list,
|
auto encrypt_provider::get_file_list(
|
||||||
std::string & /* marker */) const
|
api_file_list &list, std::string & /* marker */) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto &cfg{get_encrypt_config()};
|
const auto &cfg{get_encrypt_config()};
|
||||||
@ -359,9 +355,8 @@ auto encrypt_provider::get_file_list(api_file_list &list,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encrypt_provider::get_file_size(const std::string &api_path,
|
auto encrypt_provider::get_file_size(
|
||||||
std::uint64_t &file_size) const
|
const std::string &api_path, std::uint64_t &file_size) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -382,10 +377,9 @@ auto encrypt_provider::get_file_size(const std::string &api_path,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encrypt_provider::get_filesystem_item(const std::string &api_path,
|
auto encrypt_provider::get_filesystem_item(
|
||||||
bool directory,
|
const std::string &api_path, bool directory,
|
||||||
filesystem_item &fsi) const
|
filesystem_item &fsi) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
std::string source_path;
|
std::string source_path;
|
||||||
if (directory) {
|
if (directory) {
|
||||||
auto result{db_->get_directory_source_path(api_path, source_path)};
|
auto result{db_->get_directory_source_path(api_path, source_path)};
|
||||||
@ -436,10 +430,9 @@ auto encrypt_provider::get_filesystem_item_from_source_path(
|
|||||||
return get_filesystem_item(api_path, false, fsi);
|
return get_filesystem_item(api_path, false, fsi);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encrypt_provider::get_filesystem_item_and_file(const std::string &api_path,
|
auto encrypt_provider::get_filesystem_item_and_file(
|
||||||
api_file &file,
|
const std::string &api_path, api_file &file,
|
||||||
filesystem_item &fsi) const
|
filesystem_item &fsi) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -565,8 +558,8 @@ auto encrypt_provider::is_directory(const std::string &api_path,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encrypt_provider::is_file(const std::string &api_path, bool &exists) const
|
auto encrypt_provider::is_file(const std::string &api_path,
|
||||||
-> api_error {
|
bool &exists) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -917,9 +910,13 @@ auto encrypt_provider::start(api_item_added_callback /*api_item_added*/,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void encrypt_provider::stop() {
|
void encrypt_provider::stop() {
|
||||||
event_system::instance().raise<service_stop_begin>("encrypt_provider");
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
"encrypt_provider");
|
||||||
polling::instance().remove_callback("check_deleted");
|
polling::instance().remove_callback("check_deleted");
|
||||||
db_.reset();
|
db_.reset();
|
||||||
event_system::instance().raise<service_stop_end>("encrypt_provider");
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
"encrypt_provider");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -43,9 +43,9 @@
|
|||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
[[nodiscard]] auto set_request_path(auto &request,
|
[[nodiscard]] auto
|
||||||
const std::string &object_name)
|
set_request_path(auto &request,
|
||||||
-> repertory::api_error {
|
const std::string &object_name) -> repertory::api_error {
|
||||||
request.path = object_name;
|
request.path = object_name;
|
||||||
if (request.path.substr(1U).size() > repertory::max_s3_object_name_length) {
|
if (request.path.substr(1U).size() > repertory::max_s3_object_name_length) {
|
||||||
return repertory::api_error::name_too_long;
|
return repertory::api_error::name_too_long;
|
||||||
@ -59,9 +59,8 @@ namespace repertory {
|
|||||||
s3_provider::s3_provider(app_config &config, i_http_comm &comm)
|
s3_provider::s3_provider(app_config &config, i_http_comm &comm)
|
||||||
: base_provider(config, comm) {}
|
: base_provider(config, comm) {}
|
||||||
|
|
||||||
auto s3_provider::add_if_not_found(api_file &file,
|
auto s3_provider::add_if_not_found(
|
||||||
const std::string &object_name) const
|
api_file &file, const std::string &object_name) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
api_meta_map meta{};
|
api_meta_map meta{};
|
||||||
auto res{get_item_meta(file.api_path, meta)};
|
auto res{get_item_meta(file.api_path, meta)};
|
||||||
if (res == api_error::item_not_found) {
|
if (res == api_error::item_not_found) {
|
||||||
@ -89,7 +88,7 @@ auto s3_provider::convert_api_date(std::string_view date) -> std::uint64_t {
|
|||||||
1000000UL,
|
1000000UL,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tm tm1{};
|
struct tm tm1 {};
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||||
return nanos + utils::time::windows_time_t_to_unix_time(_mkgmtime(&tm1));
|
return nanos + utils::time::windows_time_t_to_unix_time(_mkgmtime(&tm1));
|
||||||
@ -158,9 +157,8 @@ auto s3_provider::create_directory_impl(const std::string &api_path,
|
|||||||
utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path));
|
utils::path::create_api_path(is_encrypted ? meta[META_KEY] : api_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::create_directory_paths(const std::string &api_path,
|
auto s3_provider::create_directory_paths(
|
||||||
const std::string &key) const
|
const std::string &api_path, const std::string &key) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
if (api_path == "/") {
|
if (api_path == "/") {
|
||||||
@ -323,9 +321,8 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_directory_items_impl(const std::string &api_path,
|
auto s3_provider::get_directory_items_impl(
|
||||||
directory_item_list &list) const
|
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto &cfg{get_s3_config()};
|
const auto &cfg{get_s3_config()};
|
||||||
@ -483,8 +480,8 @@ auto s3_provider::get_directory_items_impl(const std::string &api_path,
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_file(const std::string &api_path, api_file &file) const
|
auto s3_provider::get_file(const std::string &api_path,
|
||||||
-> api_error {
|
api_file &file) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -524,8 +521,8 @@ auto s3_provider::get_file(const std::string &api_path, api_file &file) const
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
|
auto s3_provider::get_file_list(api_file_list &list,
|
||||||
-> api_error {
|
std::string &marker) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -615,9 +612,8 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_last_modified(bool directory,
|
auto s3_provider::get_last_modified(
|
||||||
const std::string &api_path) const
|
bool directory, const std::string &api_path) const -> std::uint64_t {
|
||||||
-> std::uint64_t {
|
|
||||||
bool is_encrypted{};
|
bool is_encrypted{};
|
||||||
std::string object_name;
|
std::string object_name;
|
||||||
head_object_result result{};
|
head_object_result result{};
|
||||||
@ -627,10 +623,9 @@ auto s3_provider::get_last_modified(bool directory,
|
|||||||
: utils::time::get_time_now();
|
: utils::time::get_time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_object_info(bool directory, const std::string &api_path,
|
auto s3_provider::get_object_info(
|
||||||
bool &is_encrypted, std::string &object_name,
|
bool directory, const std::string &api_path, bool &is_encrypted,
|
||||||
head_object_result &result) const
|
std::string &object_name, head_object_result &result) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -690,12 +685,10 @@ auto s3_provider::get_object_info(bool directory, const std::string &api_path,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_object_list(std::string &response_data,
|
auto s3_provider::get_object_list(
|
||||||
long &response_code,
|
std::string &response_data, long &response_code,
|
||||||
std::optional<std::string> delimiter,
|
std::optional<std::string> delimiter, std::optional<std::string> prefix,
|
||||||
std::optional<std::string> prefix,
|
std::optional<std::string> token) const -> bool {
|
||||||
std::optional<std::string> token) const
|
|
||||||
-> bool {
|
|
||||||
curl::requests::http_get get{};
|
curl::requests::http_get get{};
|
||||||
get.allow_timeout = true;
|
get.allow_timeout = true;
|
||||||
get.aws_service = "aws:amz:" + get_s3_config().region + ":s3";
|
get.aws_service = "aws:amz:" + get_s3_config().region + ":s3";
|
||||||
@ -723,8 +716,8 @@ auto s3_provider::get_total_drive_space() const -> std::uint64_t {
|
|||||||
return std::numeric_limits<std::int64_t>::max() / std::int64_t(2);
|
return std::numeric_limits<std::int64_t>::max() / std::int64_t(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::is_directory(const std::string &api_path, bool &exists) const
|
auto s3_provider::is_directory(const std::string &api_path,
|
||||||
-> api_error {
|
bool &exists) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -752,8 +745,8 @@ auto s3_provider::is_directory(const std::string &api_path, bool &exists) const
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::is_file(const std::string &api_path, bool &exists) const
|
auto s3_provider::is_file(const std::string &api_path,
|
||||||
-> api_error {
|
bool &exists) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1011,8 +1004,8 @@ auto s3_provider::rename_file(const std::string & /* from_api_path */,
|
|||||||
return api_error::not_implemented;
|
return api_error::not_implemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::set_meta_key(const std::string &api_path, api_meta_map &meta)
|
auto s3_provider::set_meta_key(const std::string &api_path,
|
||||||
-> api_error {
|
api_meta_map &meta) -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto &cfg{get_s3_config()};
|
const auto &cfg{get_s3_config()};
|
||||||
@ -1056,9 +1049,13 @@ auto s3_provider::start(api_item_added_callback api_item_added,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void s3_provider::stop() {
|
void s3_provider::stop() {
|
||||||
event_system::instance().raise<service_stop_begin>("s3_provider");
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
"s3_provider");
|
||||||
base_provider::stop();
|
base_provider::stop();
|
||||||
event_system::instance().raise<service_stop_end>("s3_provider");
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
"s3_provider");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::upload_file_impl(const std::string &api_path,
|
auto s3_provider::upload_file_impl(const std::string &api_path,
|
||||||
|
@ -48,8 +48,8 @@ namespace {
|
|||||||
return cfg.bucket;
|
return cfg.bucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto get_last_modified(const nlohmann::json &obj)
|
[[nodiscard]] auto
|
||||||
-> std::uint64_t {
|
get_last_modified(const nlohmann::json &obj) -> std::uint64_t {
|
||||||
try {
|
try {
|
||||||
return repertory::s3_provider::convert_api_date(
|
return repertory::s3_provider::convert_api_date(
|
||||||
obj["modTime"].get<std::string>());
|
obj["modTime"].get<std::string>());
|
||||||
@ -63,9 +63,8 @@ namespace repertory {
|
|||||||
sia_provider::sia_provider(app_config &config, i_http_comm &comm)
|
sia_provider::sia_provider(app_config &config, i_http_comm &comm)
|
||||||
: base_provider(config, comm) {}
|
: base_provider(config, comm) {}
|
||||||
|
|
||||||
auto sia_provider::create_directory_impl(const std::string &api_path,
|
auto sia_provider::create_directory_impl(
|
||||||
api_meta_map & /* meta */)
|
const std::string &api_path, api_meta_map & /* meta */) -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
curl::requests::http_put_file put_file{};
|
curl::requests::http_put_file put_file{};
|
||||||
@ -139,9 +138,8 @@ auto sia_provider::get_directory_item_count(const std::string &api_path) const
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sia_provider::get_directory_items_impl(const std::string &api_path,
|
auto sia_provider::get_directory_items_impl(
|
||||||
directory_item_list &list) const
|
const std::string &api_path, directory_item_list &list) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
json object_list{};
|
json object_list{};
|
||||||
@ -199,8 +197,8 @@ auto sia_provider::get_directory_items_impl(const std::string &api_path,
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sia_provider::get_file(const std::string &api_path, api_file &file) const
|
auto sia_provider::get_file(const std::string &api_path,
|
||||||
-> api_error {
|
api_file &file) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -237,9 +235,8 @@ auto sia_provider::get_file(const std::string &api_path, api_file &file) const
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sia_provider::get_file_list(api_file_list &list,
|
auto sia_provider::get_file_list(
|
||||||
std::string & /* marker */) const
|
api_file_list &list, std::string & /* marker */) const -> api_error {
|
||||||
-> api_error {
|
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
using dir_func = std::function<api_error(std::string api_path)>;
|
using dir_func = std::function<api_error(std::string api_path)>;
|
||||||
@ -443,8 +440,8 @@ auto sia_provider::get_total_drive_space() const -> std::uint64_t {
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sia_provider::is_directory(const std::string &api_path, bool &exists) const
|
auto sia_provider::is_directory(const std::string &api_path,
|
||||||
-> api_error {
|
bool &exists) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -476,8 +473,8 @@ auto sia_provider::is_directory(const std::string &api_path, bool &exists) const
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sia_provider::is_file(const std::string &api_path, bool &exists) const
|
auto sia_provider::is_file(const std::string &api_path,
|
||||||
-> api_error {
|
bool &exists) const -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -752,9 +749,13 @@ auto sia_provider::start(api_item_added_callback api_item_added,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sia_provider::stop() {
|
void sia_provider::stop() {
|
||||||
event_system::instance().raise<service_stop_begin>("sia_provider");
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
"sia_provider");
|
||||||
base_provider::stop();
|
base_provider::stop();
|
||||||
event_system::instance().raise<service_stop_end>("sia_provider");
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
"sia_provider");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sia_provider::upload_file_impl(const std::string &api_path,
|
auto sia_provider::upload_file_impl(const std::string &api_path,
|
||||||
|
@ -189,12 +189,14 @@ void server::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void server::stop() {
|
void server::stop() {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
unique_mutex_lock lock(start_stop_mutex_);
|
unique_mutex_lock lock(start_stop_mutex_);
|
||||||
if (not server_thread_) {
|
if (not server_thread_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_begin>("server");
|
event_system::instance().raise<service_stop_begin>(function_name, "server");
|
||||||
|
|
||||||
server_->stop();
|
server_->stop();
|
||||||
|
|
||||||
@ -209,6 +211,6 @@ void server::stop() {
|
|||||||
server_.reset();
|
server_.reset();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_end>("server");
|
event_system::instance().raise<service_stop_end>(function_name, "server");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -145,12 +145,14 @@ void polling::start(app_config *config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void polling::stop() {
|
void polling::stop() {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
mutex_lock lock(start_stop_mutex_);
|
mutex_lock lock(start_stop_mutex_);
|
||||||
if (not frequency_threads_.at(0U)) {
|
if (not frequency_threads_.at(0U)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_begin>("polling");
|
event_system::instance().raise<service_stop_begin>(function_name, "polling");
|
||||||
|
|
||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
@ -169,6 +171,6 @@ void polling::stop() {
|
|||||||
thread.reset();
|
thread.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_end>("polling");
|
event_system::instance().raise<service_stop_end>(function_name, "polling");
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
@ -57,12 +57,15 @@ void single_thread_service_base::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void single_thread_service_base::stop() {
|
void single_thread_service_base::stop() {
|
||||||
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
unique_mutex_lock lock(mtx_);
|
unique_mutex_lock lock(mtx_);
|
||||||
if (not thread_) {
|
if (not thread_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_begin>(service_name_);
|
event_system::instance().raise<service_stop_begin>(function_name,
|
||||||
|
service_name_);
|
||||||
|
|
||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
@ -77,6 +80,7 @@ void single_thread_service_base::stop() {
|
|||||||
|
|
||||||
on_stop();
|
on_stop();
|
||||||
|
|
||||||
event_system::instance().raise<service_stop_end>(service_name_);
|
event_system::instance().raise<service_stop_end>(function_name,
|
||||||
|
service_name_);
|
||||||
}
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
Reference in New Issue
Block a user