refactor
This commit is contained in:
parent
5e15a927f1
commit
c52f7e84e6
@ -93,8 +93,9 @@ void remove_stalled(std::string_view download_id, std::string_view title,
|
|||||||
const server_cfg &server, data_db *state_db) {
|
const server_cfg &server, data_db *state_db) {
|
||||||
MONITARR_USES_FUNCTION_NAME();
|
MONITARR_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
fmt::println("remove and block {}|{}|{}|{}", server.id, server.url, title,
|
utils::error::handle_info(
|
||||||
download_id);
|
function_name, fmt::format("remove and block {}|{}|{}|{}", server.id,
|
||||||
|
server.url, title, download_id));
|
||||||
|
|
||||||
if (state_db != nullptr) {
|
if (state_db != nullptr) {
|
||||||
state_db->remove(download_id);
|
state_db->remove(download_id);
|
||||||
|
@ -29,15 +29,19 @@ auto data_db::get(std::string_view download_id) const
|
|||||||
|
|
||||||
return res.IsNotFound() ? rocksdb::Status{} : res;
|
return res.IsNotFound() ? rocksdb::Status{} : res;
|
||||||
})) {
|
})) {
|
||||||
fmt::println("failed to get|{}", download_id);
|
utils::error::handle_exception(
|
||||||
|
function_name, fmt::format("failed to get|{}", download_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void data_db::open(std::string_view data_dir) {
|
void data_db::open(std::string_view data_dir) {
|
||||||
|
MONITARR_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
auto db_path = utils::path::combine(data_dir, {"state_db"});
|
auto db_path = utils::path::combine(data_dir, {"state_db"});
|
||||||
fmt::println("opening database|{}", db_path);
|
utils::error::handle_exception(function_name,
|
||||||
|
fmt::format("opening database|{}", db_path));
|
||||||
|
|
||||||
rocksdb::Options options{};
|
rocksdb::Options options{};
|
||||||
options.create_if_missing = true;
|
options.create_if_missing = true;
|
||||||
@ -114,7 +118,8 @@ void data_db::remove(std::string_view download_id) {
|
|||||||
[&download_id](rocksdb::Transaction *txn) -> auto {
|
[&download_id](rocksdb::Transaction *txn) -> auto {
|
||||||
return txn->Delete(download_id);
|
return txn->Delete(download_id);
|
||||||
})) {
|
})) {
|
||||||
fmt::println("failed to remove|{}", download_id);
|
utils::error::handle_exception(
|
||||||
|
function_name, fmt::format("failed to remove|{}", download_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +130,9 @@ void data_db::set(const data_entry &entry) {
|
|||||||
function_name, [&entry](rocksdb::Transaction *txn) -> auto {
|
function_name, [&entry](rocksdb::Transaction *txn) -> auto {
|
||||||
return txn->Put(entry.download_id, nlohmann::json(entry).dump());
|
return txn->Put(entry.download_id, nlohmann::json(entry).dump());
|
||||||
})) {
|
})) {
|
||||||
fmt::println("failed to set|{}", nlohmann::json(entry).dump(2));
|
utils::error::handle_exception(
|
||||||
|
function_name,
|
||||||
|
fmt::format("failed to set|{}", nlohmann::json(entry).dump(2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace monitarr
|
} // namespace monitarr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user