This commit is contained in:
Scott E. Graves 2025-02-19 13:16:07 -06:00
parent 5e15a927f1
commit c52f7e84e6
2 changed files with 14 additions and 6 deletions

View File

@ -93,8 +93,9 @@ void remove_stalled(std::string_view download_id, std::string_view title,
const server_cfg &server, data_db *state_db) {
MONITARR_USES_FUNCTION_NAME();
fmt::println("remove and block {}|{}|{}|{}", server.id, server.url, title,
download_id);
utils::error::handle_info(
function_name, fmt::format("remove and block {}|{}|{}|{}", server.id,
server.url, title, download_id));
if (state_db != nullptr) {
state_db->remove(download_id);

View File

@ -29,15 +29,19 @@ auto data_db::get(std::string_view download_id) const
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;
}
void data_db::open(std::string_view data_dir) {
MONITARR_USES_FUNCTION_NAME();
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{};
options.create_if_missing = true;
@ -114,7 +118,8 @@ void data_db::remove(std::string_view download_id) {
[&download_id](rocksdb::Transaction *txn) -> auto {
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 {
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