Compare commits
4 Commits
5dff8927da
...
e9b202f5c8
Author | SHA1 | Date | |
---|---|---|---|
e9b202f5c8 | |||
bc3005a6a4 | |||
8cf19e0594 | |||
b137b57dbc |
@ -4,6 +4,8 @@
|
||||
|
||||
### Issues
|
||||
|
||||
* \#10 Address compiler warnings
|
||||
|
||||
### Changes from v2.0.0-rc
|
||||
|
||||
* Removed MSVC compilation support (MinGW-64 should be used)
|
||||
|
@ -46,7 +46,7 @@ create_directory(int argc, char *argv[], const std::string &data_directory,
|
||||
argc, argv, utils::cli::options::create_directory_option,
|
||||
api_path)) == exit_code::success) {
|
||||
lock_data lock(pt, unique_id);
|
||||
const auto res = lock.grab_lock(1u);
|
||||
const auto lock_res = lock.grab_lock(1u);
|
||||
/* if (res == lock_result::locked) { */
|
||||
/* auto port = app_config::default_api_port(pt); */
|
||||
/* utils::cli::get_api_authentication_data(user, password, port, pt,
|
||||
@ -57,7 +57,7 @@ create_directory(int argc, char *argv[], const std::string &data_directory,
|
||||
/* std::cout << static_cast<int>(response.response_type) << std::endl; */
|
||||
/* std::cout << response.data.dump(2) << std::endl; */
|
||||
/* } else */
|
||||
if (res == lock_result::success) {
|
||||
if (lock_res == lock_result::success) {
|
||||
std::cout << "creating directory: '" << api_path << "'" << std::endl;
|
||||
app_config config(pt, data_directory);
|
||||
s3_comm comm(config);
|
||||
@ -65,8 +65,8 @@ create_directory(int argc, char *argv[], const std::string &data_directory,
|
||||
std::cout << api_error_to_string(res) << std::endl;
|
||||
ret = exit_code::success;
|
||||
} else {
|
||||
std::cout << "failed to grab lock: '" << static_cast<int>(res) << "'"
|
||||
<< std::endl;
|
||||
std::cout << "failed to grab lock: '" << static_cast<int>(lock_res)
|
||||
<< "'" << std::endl;
|
||||
ret = exit_code::lock_failed;
|
||||
}
|
||||
}
|
||||
|
@ -42,18 +42,8 @@ list_objects(int /* argc */, char * /* argv */[],
|
||||
|
||||
if (pt == provider_type::s3) {
|
||||
lock_data lock(pt, unique_id);
|
||||
const auto res = lock.grab_lock(1u);
|
||||
/* if (res == lock_result::locked) { */
|
||||
/* 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) {
|
||||
auto lock_res = lock.grab_lock(1u);
|
||||
if (lock_res == lock_result::success) {
|
||||
app_config config(pt, data_directory);
|
||||
s3_comm comm(config);
|
||||
std::vector<directory_item> list{};
|
||||
@ -67,7 +57,7 @@ list_objects(int /* argc */, char * /* argv */[],
|
||||
std::cout << api_error_to_string(res) << std::endl;
|
||||
}
|
||||
} else {
|
||||
std::cout << "failed to grab lock: '" << static_cast<int>(res) << "'"
|
||||
std::cout << "failed to grab lock: '" << static_cast<int>(lock_res) << "'"
|
||||
<< std::endl;
|
||||
ret = exit_code::lock_failed;
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ using event_consumer = event_system::event_consumer;
|
||||
|
||||
#define E_CAST(t) ((std::string)t)
|
||||
#define E_DOUBLE(d) std::to_string(d)
|
||||
#define E_DOUBLE_PRECISE(d) \
|
||||
#define E_DOUBLE_PRECISE(dbl_val) \
|
||||
([](const double &d) -> std::string { \
|
||||
std::stringstream ss; \
|
||||
ss << std::fixed << std::setprecision(2) << d; \
|
||||
return ss.str(); \
|
||||
})(d)
|
||||
})(dbl_val)
|
||||
#define E_FROM_BOOL(t) std::to_string(t)
|
||||
#define E_FROM_EXCEPTION(e) std::string(e.what() ? e.what() : "")
|
||||
#define E_FROM_INT32(t) std::to_string(t)
|
||||
@ -69,8 +69,9 @@ using event_consumer = event_system::event_consumer;
|
||||
#define E_PROP(type, name, short_name, ts) \
|
||||
private: \
|
||||
void init_##short_name(const type &val) { \
|
||||
ss_ << "|" << #short_name << "|" << ts(val); \
|
||||
j_[#name] = ts(val); \
|
||||
auto ts_val = ts(val); \
|
||||
ss_ << "|" << #short_name << "|" << ts_val; \
|
||||
j_[#name] = ts_val; \
|
||||
} \
|
||||
\
|
||||
public: \
|
||||
|
@ -103,13 +103,13 @@ void file_manager::open_file::download_chunk(std::size_t chunk,
|
||||
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()) &&
|
||||
not read_state_[chunk]) {
|
||||
if (active_downloads_.find(chunk) != active_downloads_.end()) {
|
||||
if (not skip_active) {
|
||||
auto active_download = active_downloads_.at(chunk);
|
||||
file_lock.unlock();
|
||||
download_lock.unlock();
|
||||
|
||||
active_download->wait();
|
||||
}
|
||||
@ -129,7 +129,7 @@ void file_manager::open_file::download_chunk(std::size_t chunk,
|
||||
read_state_.count());
|
||||
|
||||
active_downloads_[chunk] = std::make_shared<download>();
|
||||
file_lock.unlock();
|
||||
download_lock.unlock();
|
||||
|
||||
if (should_reset) {
|
||||
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) {
|
||||
recur_mutex_lock file_lock(file_mtx_);
|
||||
recur_mutex_lock reader_lock(file_mtx_);
|
||||
read_chunk_index_ = read_chunk;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
unique_recur_mutex_lock file_lock(file_mtx_);
|
||||
unique_recur_mutex_lock write_lock(file_mtx_);
|
||||
if (stop_requested_) {
|
||||
return api_error::download_stopped;
|
||||
}
|
||||
file_lock.unlock();
|
||||
write_lock.unlock();
|
||||
|
||||
const auto start_chunk_index =
|
||||
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();
|
||||
}
|
||||
|
||||
file_lock.lock();
|
||||
write_lock.lock();
|
||||
if ((write_offset + data.size()) > fsi_.size) {
|
||||
auto res = resize(write_offset + data.size());
|
||||
if (res != api_error::success) {
|
||||
|
@ -264,18 +264,18 @@ auto file_manager::ring_buffer_open_file::read(std::size_t read_size,
|
||||
res = do_io([this, &buffer, &chunk, &data, read_offset,
|
||||
&to_read]() -> api_error {
|
||||
std::size_t bytes_read{};
|
||||
auto res = nf_->read_bytes(buffer.data(), buffer.size(),
|
||||
auto ret = nf_->read_bytes(buffer.data(), buffer.size(),
|
||||
((chunk % ring_state_.size()) * chunk_size_),
|
||||
bytes_read)
|
||||
? api_error::success
|
||||
: api_error::os_error;
|
||||
if (res == api_error::success) {
|
||||
if (ret == api_error::success) {
|
||||
data.insert(data.end(), buffer.begin() + read_offset,
|
||||
buffer.begin() + read_offset + to_read);
|
||||
reset_timeout();
|
||||
}
|
||||
|
||||
return res;
|
||||
return ret;
|
||||
});
|
||||
read_offset = 0u;
|
||||
read_size -= to_read;
|
||||
|
@ -407,8 +407,7 @@ void base_provider::remove_deleted_files() {
|
||||
removed_files.pop_back();
|
||||
|
||||
bool exists{};
|
||||
auto res = is_directory(api_path, exists);
|
||||
if (res != api_error::success) {
|
||||
if (is_directory(api_path, exists) != api_error::success) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -421,7 +420,7 @@ void base_provider::remove_deleted_files() {
|
||||
fm_->perform_locked_operation(
|
||||
[this, &api_path, &source_path](i_provider &) -> bool {
|
||||
if (fm_->has_no_open_file_handles()) {
|
||||
const auto res = meta_db_->remove_item_meta(api_path);
|
||||
auto res = meta_db_->remove_item_meta(api_path);
|
||||
if (res == api_error::success) {
|
||||
event_system::instance().raise<file_removed_externally>(
|
||||
api_path, source_path);
|
||||
|
@ -222,21 +222,23 @@ auto encrypt_provider::get_directory_items(const std::string &api_path,
|
||||
for (const auto &dir_entry :
|
||||
std::filesystem::directory_iterator(source_path)) {
|
||||
try {
|
||||
std::string api_path{};
|
||||
std::string entry_api_path{};
|
||||
if (dir_entry.is_directory()) {
|
||||
db_->Get(rocksdb::ReadOptions(), dir_family_,
|
||||
dir_entry.path().string(), &api_path);
|
||||
if (api_path.empty()) {
|
||||
dir_entry.path().string(), &entry_api_path);
|
||||
if (entry_api_path.empty()) {
|
||||
const auto cfg = config_.get_encrypt_config();
|
||||
for (const auto &child_dir_entry :
|
||||
std::filesystem::directory_iterator(dir_entry.path())) {
|
||||
if (process_directory_entry(child_dir_entry, cfg, api_path)) {
|
||||
api_path = utils::path::get_parent_api_path(api_path);
|
||||
if (process_directory_entry(child_dir_entry, cfg,
|
||||
entry_api_path)) {
|
||||
entry_api_path =
|
||||
utils::path::get_parent_api_path(entry_api_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (api_path.empty()) {
|
||||
if (entry_api_path.empty()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -246,16 +248,16 @@ auto encrypt_provider::get_directory_items(const std::string &api_path,
|
||||
dir_entry.path().string(), &api_path_data);
|
||||
if (api_path_data.empty()) {
|
||||
const auto cfg = config_.get_encrypt_config();
|
||||
if (not process_directory_entry(dir_entry, cfg, api_path)) {
|
||||
if (not process_directory_entry(dir_entry, cfg, entry_api_path)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
api_path =
|
||||
entry_api_path =
|
||||
json::parse(api_path_data).at("api_path").get<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
auto file = create_api_file(api_path, dir_entry.is_directory(),
|
||||
auto file = create_api_file(entry_api_path, dir_entry.is_directory(),
|
||||
dir_entry.path().string());
|
||||
|
||||
directory_item di{};
|
||||
@ -464,13 +466,13 @@ auto encrypt_provider::get_filesystem_item(const std::string &api_path,
|
||||
}
|
||||
|
||||
if (directory) {
|
||||
std::string api_path{};
|
||||
db_->Get(rocksdb::ReadOptions(), dir_family_, source_path, &api_path);
|
||||
if (api_path.empty()) {
|
||||
std::string db_api_path{};
|
||||
db_->Get(rocksdb::ReadOptions(), dir_family_, source_path, &db_api_path);
|
||||
if (db_api_path.empty()) {
|
||||
return api_error::item_not_found;
|
||||
}
|
||||
fsi.api_parent = utils::path::get_parent_api_path(api_path);
|
||||
fsi.api_path = api_path;
|
||||
fsi.api_parent = utils::path::get_parent_api_path(db_api_path);
|
||||
fsi.api_path = db_api_path;
|
||||
fsi.directory = true;
|
||||
fsi.size = 0U;
|
||||
fsi.source_path = source_path;
|
||||
|
@ -961,8 +961,8 @@ void sia_provider::remove_deleted_files() {
|
||||
if (get_item_meta(iterator->key().ToString(), meta) == api_error::success) {
|
||||
if (utils::string::to_bool(meta[META_DIRECTORY])) {
|
||||
bool exists{};
|
||||
auto res = is_directory(iterator->key().ToString(), exists);
|
||||
if (res != api_error::success) {
|
||||
if (is_directory(iterator->key().ToString(), exists) !=
|
||||
api_error::success) {
|
||||
continue;
|
||||
}
|
||||
if (not exists) {
|
||||
@ -973,8 +973,7 @@ void sia_provider::remove_deleted_files() {
|
||||
}
|
||||
|
||||
bool exists{};
|
||||
auto res = is_file(iterator->key().ToString(), exists);
|
||||
if (res != api_error::success) {
|
||||
if (is_file(iterator->key().ToString(), exists) != api_error::success) {
|
||||
continue;
|
||||
}
|
||||
if (not exists) {
|
||||
|
@ -162,8 +162,8 @@ TEST_F(directory_db_test, get_file) {
|
||||
|
||||
api_file file{};
|
||||
EXPECT_EQ(api_error::success,
|
||||
db_->get_file("/cow.txt", file, [](api_file &file) {
|
||||
EXPECT_STREQ("/cow.txt", file.api_path.c_str());
|
||||
db_->get_file("/cow.txt", file, [](api_file &cur_file) {
|
||||
EXPECT_STREQ("/cow.txt", cur_file.api_path.c_str());
|
||||
}));
|
||||
EXPECT_STREQ("/cow.txt", file.api_path.c_str());
|
||||
}
|
||||
|
@ -89,9 +89,9 @@ TEST(open_file, properly_initializes_state_based_on_chunk_size) {
|
||||
|
||||
EXPECT_CALL(um, remove_resume)
|
||||
.WillOnce(
|
||||
[&fsi](const std::string &api_path, const std::string &source_path) {
|
||||
[&fsi](const std::string &api_path, const std::string &source_path2) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path2);
|
||||
});
|
||||
|
||||
file_manager::open_file o(1u, 0U, fsi, mp, um);
|
||||
@ -143,15 +143,15 @@ TEST(open_file, will_change_source_path_if_file_size_is_greater_than_0) {
|
||||
|
||||
EXPECT_CALL(um, remove_resume)
|
||||
.WillOnce(
|
||||
[&fsi](const std::string &api_path, const std::string &source_path) {
|
||||
[&fsi](const std::string &api_path, const std::string &source_path2) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path2);
|
||||
});
|
||||
|
||||
EXPECT_CALL(mp, set_item_meta(fsi.api_path, META_SOURCE, _))
|
||||
.WillOnce([&fsi](const std::string &, const std::string &,
|
||||
const std::string &source_path) -> api_error {
|
||||
EXPECT_STRNE(fsi.source_path.c_str(), source_path.c_str());
|
||||
const std::string &source_path2) -> api_error {
|
||||
EXPECT_STRNE(fsi.source_path.c_str(), source_path2.c_str());
|
||||
return api_error::success;
|
||||
});
|
||||
|
||||
@ -248,9 +248,9 @@ TEST(open_file, write_with_incomplete_download) {
|
||||
|
||||
EXPECT_CALL(um, store_resume)
|
||||
.Times(2)
|
||||
.WillRepeatedly([&fsi](const i_open_file &o) {
|
||||
EXPECT_EQ(fsi.api_path, o.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, o.get_source_path());
|
||||
.WillRepeatedly([&fsi](const i_open_file &cur_file) {
|
||||
EXPECT_EQ(fsi.api_path, cur_file.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, cur_file.get_source_path());
|
||||
});
|
||||
|
||||
data_buffer data = {10, 9, 8};
|
||||
@ -325,9 +325,9 @@ TEST(open_file, write_new_file) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
});
|
||||
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &o) {
|
||||
EXPECT_EQ(fsi.api_path, o.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, o.get_source_path());
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &cur_file) {
|
||||
EXPECT_EQ(fsi.api_path, cur_file.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, cur_file.get_source_path());
|
||||
});
|
||||
|
||||
std::size_t bytes_written{};
|
||||
@ -414,9 +414,9 @@ TEST(open_file, write_new_file_multiple_chunks) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
});
|
||||
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &o) {
|
||||
EXPECT_EQ(fsi.api_path, o.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, o.get_source_path());
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &cur_file) {
|
||||
EXPECT_EQ(fsi.api_path, cur_file.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, cur_file.get_source_path());
|
||||
});
|
||||
|
||||
std::size_t bytes_written{};
|
||||
@ -478,13 +478,13 @@ TEST(open_file, resize_file_to_0_bytes) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
});
|
||||
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &o) {
|
||||
EXPECT_EQ(fsi.api_path, o.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, o.get_source_path());
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &cur_file) {
|
||||
EXPECT_EQ(fsi.api_path, cur_file.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, cur_file.get_source_path());
|
||||
});
|
||||
EXPECT_CALL(um, store_resume).WillOnce([&fsi](const i_open_file &o) {
|
||||
EXPECT_EQ(fsi.api_path, o.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, o.get_source_path());
|
||||
EXPECT_CALL(um, store_resume).WillOnce([&fsi](const i_open_file &cur_file) {
|
||||
EXPECT_EQ(fsi.api_path, cur_file.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, cur_file.get_source_path());
|
||||
});
|
||||
|
||||
EXPECT_EQ(api_error::success, o.resize(0u));
|
||||
@ -532,9 +532,9 @@ TEST(open_file, resize_file_by_full_chunk) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
});
|
||||
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &o) {
|
||||
EXPECT_EQ(fsi.api_path, o.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, o.get_source_path());
|
||||
EXPECT_CALL(um, queue_upload).WillOnce([&fsi](const i_open_file &cur_file) {
|
||||
EXPECT_EQ(fsi.api_path, cur_file.get_api_path());
|
||||
EXPECT_EQ(fsi.source_path, cur_file.get_source_path());
|
||||
});
|
||||
|
||||
EXPECT_EQ(api_error::success, o.resize(test_chunk_size * 3u));
|
||||
@ -583,9 +583,9 @@ TEST(open_file, can_add_handle) {
|
||||
.WillOnce(Return(api_error::success));
|
||||
EXPECT_CALL(um, remove_resume)
|
||||
.WillOnce(
|
||||
[&fsi](const std::string &api_path, const std::string &source_path) {
|
||||
[&fsi](const std::string &api_path, const std::string &source_path2) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path2);
|
||||
});
|
||||
|
||||
event_capture capture(
|
||||
@ -642,9 +642,9 @@ TEST(open_file, can_remove_handle) {
|
||||
|
||||
EXPECT_CALL(um, remove_resume)
|
||||
.WillOnce(
|
||||
[&fsi](const std::string &api_path, const std::string &source_path) {
|
||||
[&fsi](const std::string &api_path, const std::string &source_path2) {
|
||||
EXPECT_EQ(fsi.api_path, api_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path);
|
||||
EXPECT_EQ(fsi.source_path, source_path2);
|
||||
});
|
||||
EXPECT_CALL(mp, set_item_meta(fsi.api_path, META_SOURCE, _))
|
||||
.WillOnce(Return(api_error::success));
|
||||
|
@ -461,10 +461,10 @@ TEST(file_manager, download_is_stored_after_write_if_partially_downloaded) {
|
||||
});
|
||||
EXPECT_CALL(mp, set_item_meta("/test_write_partial_download.txt", _))
|
||||
.WillOnce(
|
||||
[](const std::string &, const api_meta_map &meta) -> api_error {
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_CHANGED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_MODIFIED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_WRITTEN).empty()));
|
||||
[](const std::string &, const api_meta_map &meta2) -> api_error {
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_CHANGED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_MODIFIED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_WRITTEN).empty()));
|
||||
return api_error::success;
|
||||
});
|
||||
EXPECT_CALL(mp, upload_file).Times(0u);
|
||||
@ -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", _))
|
||||
.WillOnce(
|
||||
[](const std::string &, const api_meta_map &meta) -> api_error {
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_CHANGED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_MODIFIED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta.at(META_WRITTEN).empty()));
|
||||
[](const std::string &, const api_meta_map &meta2) -> api_error {
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_CHANGED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_MODIFIED).empty()));
|
||||
EXPECT_NO_THROW(EXPECT_FALSE(meta2.at(META_WRITTEN).empty()));
|
||||
return api_error::success;
|
||||
});
|
||||
std::size_t bytes_written{};
|
||||
@ -977,11 +977,11 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) {
|
||||
.WillRepeatedly(Return(api_error::success));
|
||||
EXPECT_CALL(mp, upload_file)
|
||||
.WillOnce([](const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
const std::string &source_path2,
|
||||
const std::string &encryption_token,
|
||||
stop_type & /*stop_requested*/) -> api_error {
|
||||
EXPECT_STREQ("/test_evict.txt", api_path.c_str());
|
||||
EXPECT_FALSE(source_path.empty());
|
||||
EXPECT_FALSE(source_path2.empty());
|
||||
EXPECT_TRUE(encryption_token.empty());
|
||||
std::this_thread::sleep_for(3s);
|
||||
return api_error::success;
|
||||
|
@ -113,8 +113,8 @@ public:
|
||||
const get_name_callback &get_name,
|
||||
const get_token_callback &get_token, api_file &file) {
|
||||
auto f = std::find_if(list.begin(), list.end(),
|
||||
[&api_path](const auto &f) -> bool {
|
||||
return f.api_path == api_path;
|
||||
[&api_path](const auto &cur_file) -> bool {
|
||||
return cur_file.api_path == api_path;
|
||||
});
|
||||
if (f == list.end()) {
|
||||
return api_error::item_not_found;
|
||||
|
@ -30,8 +30,8 @@ TEST(lock_data, lock_and_unlock) {
|
||||
EXPECT_EQ(lock_result::success, l.grab_lock());
|
||||
|
||||
std::thread([]() {
|
||||
lock_data l(provider_type::sia, "1");
|
||||
EXPECT_EQ(lock_result::locked, l.grab_lock(10));
|
||||
lock_data l2(provider_type::sia, "1");
|
||||
EXPECT_EQ(lock_result::locked, l2.grab_lock(10));
|
||||
}).join();
|
||||
}
|
||||
|
||||
|
@ -25,16 +25,16 @@
|
||||
|
||||
namespace repertory {
|
||||
TEST(packet, encrypt_and_decrypt) {
|
||||
packet packet;
|
||||
packet.encode("test");
|
||||
packet.encrypt("moose");
|
||||
packet test_packet;
|
||||
test_packet.encode("test");
|
||||
test_packet.encrypt("moose");
|
||||
|
||||
std::uint32_t size{};
|
||||
EXPECT_EQ(0, packet.decode(size));
|
||||
EXPECT_EQ(0, packet.decrypt("moose"));
|
||||
EXPECT_EQ(0, test_packet.decode(size));
|
||||
EXPECT_EQ(0, test_packet.decrypt("moose"));
|
||||
|
||||
std::string data;
|
||||
EXPECT_EQ(0, packet.decode(data));
|
||||
EXPECT_EQ(0, test_packet.decode(data));
|
||||
|
||||
EXPECT_STREQ("test", data.c_str());
|
||||
}
|
||||
|
Reference in New Issue
Block a user