This commit is contained in:
parent
4b32664e46
commit
65096f60b1
@ -376,8 +376,8 @@ auto rdb_meta_db::update_item_meta(const std::string &api_path, json json_data)
|
||||
auto size = directory ? std::uint64_t(0U)
|
||||
: utils::string::to_uint64(
|
||||
json_data.at(META_SIZE).get<std::string>());
|
||||
auto source_path =
|
||||
directory ? "" : json_data.at(META_SOURCE).get<std::string>();
|
||||
auto source_path = directory ? std::string("")
|
||||
: json_data.at(META_SOURCE).get<std::string>();
|
||||
|
||||
if (not directory) {
|
||||
std::string orig_source_path;
|
||||
@ -413,13 +413,13 @@ auto rdb_meta_db::update_item_meta(const std::string &api_path, json json_data)
|
||||
if (not res.ok()) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
if (not source_path.empty()) {
|
||||
auto res = db_->Put(rocksdb::WriteOptions(), source_family_,
|
||||
source_path, api_path);
|
||||
if (not res.ok()) {
|
||||
return res;
|
||||
if (not source_path.empty()) {
|
||||
res = db_->Put(rocksdb::WriteOptions(), source_family_, source_path,
|
||||
api_path);
|
||||
if (not res.ok()) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ auto sqlite_meta_db::update_item_meta(const std::string &api_path,
|
||||
directory ? false : utils::string::to_bool(meta.at(META_PINNED));
|
||||
auto size = directory ? std::uint64_t(0U)
|
||||
: utils::string::to_uint64(meta.at(META_SIZE));
|
||||
auto source_path = directory ? "" : meta.at(META_SOURCE);
|
||||
auto source_path = directory ? std::string("") : meta.at(META_SOURCE);
|
||||
|
||||
meta.erase(META_DIRECTORY);
|
||||
meta.erase(META_PINNED);
|
||||
|
@ -25,20 +25,23 @@
|
||||
#include "test_common.hpp"
|
||||
|
||||
#include "app_config.hpp"
|
||||
#include "db/i_meta_db.hpp"
|
||||
#include "db/rdb_meta_db.hpp"
|
||||
#include "db/sqlite_meta_db.hpp"
|
||||
#include "events/consumers/console_consumer.hpp"
|
||||
#include "events/event_system.hpp"
|
||||
|
||||
namespace repertory {
|
||||
template <typename db_t> class meta_db_test : public ::testing::Test {
|
||||
protected:
|
||||
static std::unique_ptr<app_config> config;
|
||||
static console_consumer console_;
|
||||
static std::unique_ptr<db_t> meta_db;
|
||||
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
static std::uint64_t idx{};
|
||||
|
||||
event_system::instance().start();
|
||||
auto cfg_directory = utils::path::combine(test::get_test_output_dir(),
|
||||
{
|
||||
"meta_db_test",
|
||||
@ -51,6 +54,7 @@ protected:
|
||||
static void TearDownTestCase() {
|
||||
meta_db.reset();
|
||||
config.reset();
|
||||
event_system::instance().stop();
|
||||
}
|
||||
};
|
||||
|
||||
@ -58,6 +62,8 @@ using meta_db_types = ::testing::Types<rdb_meta_db, sqlite_meta_db>;
|
||||
|
||||
template <typename db_t> std::unique_ptr<app_config> meta_db_test<db_t>::config;
|
||||
|
||||
template <typename db_t> console_consumer meta_db_test<db_t>::console_;
|
||||
|
||||
template <typename db_t> std::unique_ptr<db_t> meta_db_test<db_t>::meta_db;
|
||||
} // namespace repertory
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user