meta db unit tests and fixes
This commit is contained in:
parent
cf1ee8db02
commit
4b32664e46
@ -357,12 +357,6 @@ auto rdb_meta_db::update_item_meta(const std::string &api_path, json json_data)
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
std::string orig_source_path;
|
||||
auto ret = get_item_meta(api_path, META_SOURCE, orig_source_path);
|
||||
if (ret != api_error::success && ret != api_error::item_not_found) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (not json_data.contains(META_PINNED)) {
|
||||
json_data[META_PINNED] = utils::string::from_bool(false);
|
||||
}
|
||||
@ -375,6 +369,7 @@ auto rdb_meta_db::update_item_meta(const std::string &api_path, json json_data)
|
||||
|
||||
auto directory =
|
||||
utils::string::to_bool(json_data.at(META_DIRECTORY).get<std::string>());
|
||||
|
||||
auto pinned = directory ? false
|
||||
: utils::string::to_bool(
|
||||
json_data.at(META_PINNED).get<std::string>());
|
||||
@ -383,13 +378,22 @@ auto rdb_meta_db::update_item_meta(const std::string &api_path, json json_data)
|
||||
json_data.at(META_SIZE).get<std::string>());
|
||||
auto source_path =
|
||||
directory ? "" : json_data.at(META_SOURCE).get<std::string>();
|
||||
if (orig_source_path != source_path && not orig_source_path.empty()) {
|
||||
ret = perform_action(function_name, [&]() -> rocksdb::Status {
|
||||
|
||||
if (not directory) {
|
||||
std::string orig_source_path;
|
||||
auto res = get_item_meta(api_path, META_SOURCE, orig_source_path);
|
||||
if (res != api_error::success && res != api_error::item_not_found) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (not orig_source_path.empty() && orig_source_path != source_path) {
|
||||
res = perform_action(function_name, [&]() -> rocksdb::Status {
|
||||
return db_->Delete(rocksdb::WriteOptions(), source_family_,
|
||||
orig_source_path);
|
||||
});
|
||||
if (ret != api_error::success && ret != api_error::item_not_found) {
|
||||
return ret;
|
||||
if (res != api_error::success && res != api_error::item_not_found) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user