\#10 Address compiler warnings

This commit is contained in:
Scott E. Graves 2023-10-30 10:54:35 -05:00
parent b137b57dbc
commit 8cf19e0594
5 changed files with 22 additions and 31 deletions

View File

@ -42,18 +42,8 @@ list_objects(int /* argc */, char * /* argv */[],
if (pt == provider_type::s3) { if (pt == provider_type::s3) {
lock_data lock(pt, unique_id); lock_data lock(pt, unique_id);
const auto res = lock.grab_lock(1u); auto lock_res = lock.grab_lock(1u);
/* if (res == lock_result::locked) { */ if (lock_res == lock_result::success) {
/* auto port = app_config::default_api_port(pt); */
/* utils::cli::get_api_authentication_data(user, password, port, pt,
* data_directory); */
/* const auto response = */
/* client({"localhost", password, port,
* user}).create_directory(api_path); */
/* std::cout << static_cast<int>(response.response_type) << std::endl; */
/* std::cout << response.data.dump(2) << std::endl; */
/* } else */
if (res == lock_result::success) {
app_config config(pt, data_directory); app_config config(pt, data_directory);
s3_comm comm(config); s3_comm comm(config);
std::vector<directory_item> list{}; std::vector<directory_item> list{};
@ -67,7 +57,7 @@ list_objects(int /* argc */, char * /* argv */[],
std::cout << api_error_to_string(res) << std::endl; std::cout << api_error_to_string(res) << std::endl;
} }
} else { } else {
std::cout << "failed to grab lock: '" << static_cast<int>(res) << "'" std::cout << "failed to grab lock: '" << static_cast<int>(lock_res) << "'"
<< std::endl; << std::endl;
ret = exit_code::lock_failed; ret = exit_code::lock_failed;
} }

View File

@ -68,9 +68,10 @@ using event_consumer = event_system::event_consumer;
#define E_PROP(type, name, short_name, ts) \ #define E_PROP(type, name, short_name, ts) \
private: \ private: \
void init_##short_name(const type &val_##name) { \ void init_##short_name(const type &val) { \
ss_ << "|" << #short_name << "|" << ts(val_##name); \ auto ts_val = ts(val); \
j_[#name] = ts(val_##name); \ ss_ << "|" << #short_name << "|" << ts_val; \
j_[#name] = ts_val; \
} \ } \
\ \
public: \ public: \

View File

@ -103,13 +103,13 @@ void file_manager::open_file::download_chunk(std::size_t chunk,
reset_timeout(); reset_timeout();
} }
unique_recur_mutex_lock file_lock(file_mtx_); unique_recur_mutex_lock download_lock(file_mtx_);
if ((get_api_error() == api_error::success) && (chunk < read_state_.size()) && if ((get_api_error() == api_error::success) && (chunk < read_state_.size()) &&
not read_state_[chunk]) { not read_state_[chunk]) {
if (active_downloads_.find(chunk) != active_downloads_.end()) { if (active_downloads_.find(chunk) != active_downloads_.end()) {
if (not skip_active) { if (not skip_active) {
auto active_download = active_downloads_.at(chunk); auto active_download = active_downloads_.at(chunk);
file_lock.unlock(); download_lock.unlock();
active_download->wait(); active_download->wait();
} }
@ -129,7 +129,7 @@ void file_manager::open_file::download_chunk(std::size_t chunk,
read_state_.count()); read_state_.count());
active_downloads_[chunk] = std::make_shared<download>(); active_downloads_[chunk] = std::make_shared<download>();
file_lock.unlock(); download_lock.unlock();
if (should_reset) { if (should_reset) {
reset_timeout(); reset_timeout();
@ -486,7 +486,7 @@ auto file_manager::open_file::close() -> bool {
} }
void file_manager::open_file::update_background_reader(std::size_t read_chunk) { void file_manager::open_file::update_background_reader(std::size_t read_chunk) {
recur_mutex_lock file_lock(file_mtx_); recur_mutex_lock reader_lock(file_mtx_);
read_chunk_index_ = read_chunk; read_chunk_index_ = read_chunk;
if (not reader_thread_ && not stop_requested_) { if (not reader_thread_ && not stop_requested_) {
@ -533,11 +533,11 @@ auto file_manager::open_file::write(std::uint64_t write_offset,
return api_error::success; return api_error::success;
} }
unique_recur_mutex_lock file_lock(file_mtx_); unique_recur_mutex_lock write_lock(file_mtx_);
if (stop_requested_) { if (stop_requested_) {
return api_error::download_stopped; return api_error::download_stopped;
} }
file_lock.unlock(); write_lock.unlock();
const auto start_chunk_index = const auto start_chunk_index =
static_cast<std::size_t>(write_offset / chunk_size_); static_cast<std::size_t>(write_offset / chunk_size_);
@ -552,7 +552,7 @@ auto file_manager::open_file::write(std::uint64_t write_offset,
return get_api_error(); return get_api_error();
} }
file_lock.lock(); write_lock.lock();
if ((write_offset + data.size()) > fsi_.size) { if ((write_offset + data.size()) > fsi_.size) {
auto res = resize(write_offset + data.size()); auto res = resize(write_offset + data.size());
if (res != api_error::success) { if (res != api_error::success) {

View File

@ -611,10 +611,10 @@ TEST(file_manager, upload_occurs_after_write_if_fully_downloaded) {
}); });
EXPECT_CALL(mp, set_item_meta("/test_write_full_download.txt", _)) EXPECT_CALL(mp, set_item_meta("/test_write_full_download.txt", _))
.WillOnce( .WillOnce(
[](const std::string &, const api_meta_map &meta) -> api_error { [](const std::string &, const api_meta_map &meta2) -> api_error {
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_CHANGED).empty())); EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_CHANGED).empty()));
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_MODIFIED).empty())); EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_MODIFIED).empty()));
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_WRITTEN).empty())); EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_WRITTEN).empty()));
return api_error::success; return api_error::success;
}); });
std::size_t bytes_written{}; std::size_t bytes_written{};
@ -977,11 +977,11 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) {
.WillRepeatedly(Return(api_error::success)); .WillRepeatedly(Return(api_error::success));
EXPECT_CALL(mp, upload_file) EXPECT_CALL(mp, upload_file)
.WillOnce([](const std::string &api_path, .WillOnce([](const std::string &api_path,
const std::string &source_path, const std::string &source_path2,
const std::string &encryption_token, const std::string &encryption_token,
stop_type & /*stop_requested*/) -> api_error { stop_type & /*stop_requested*/) -> api_error {
EXPECT_STREQ("/test_evict.txt", api_path.c_str()); EXPECT_STREQ("/test_evict.txt", api_path.c_str());
EXPECT_FALSE(source_path.empty()); EXPECT_FALSE(source_path2.empty());
EXPECT_TRUE(encryption_token.empty()); EXPECT_TRUE(encryption_token.empty());
std::this_thread::sleep_for(3s); std::this_thread::sleep_for(3s);
return api_error::success; return api_error::success;

View File

@ -113,8 +113,8 @@ public:
const get_name_callback &get_name, const get_name_callback &get_name,
const get_token_callback &get_token, api_file &file) { const get_token_callback &get_token, api_file &file) {
auto f = std::find_if(list.begin(), list.end(), auto f = std::find_if(list.begin(), list.end(),
[&api_path](const auto &f) -> bool { [&api_path](const auto &file) -> bool {
return f.api_path == api_path; return file.api_path == api_path;
}); });
if (f == list.end()) { if (f == list.end()) {
return api_error::item_not_found; return api_error::item_not_found;