refactor: remove tr_variantDictFindStr() from transmission-daemon (#2165)

* refactor: remove tr_variantDictFindStr from transmission-daemon
This commit is contained in:
Charles Kerr 2021-11-14 22:49:56 -06:00 committed by GitHub
parent af8e9e66b9
commit b1aeaa3dcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -725,19 +725,17 @@ static int daemon_start(void* varg, [[maybe_unused]] bool foreground)
/* maybe add a watchdir */
if (tr_variantDictFindBool(settings, TR_KEY_watch_dir_enabled, &boolVal) && boolVal)
{
char const* dir;
bool force_generic;
auto force_generic = bool{ false };
(void)tr_variantDictFindBool(settings, key_watch_dir_force_generic, &force_generic);
if (!tr_variantDictFindBool(settings, key_watch_dir_force_generic, &force_generic))
auto dir = std::string_view{};
(void)tr_variantDictFindStrView(settings, TR_KEY_watch_dir, &dir);
if (!std::empty(dir))
{
force_generic = false;
}
tr_logAddInfo("Watching \"%" TR_PRIsv "\" for new .torrent files", TR_PRIsv_ARG(dir));
if (tr_variantDictFindStr(settings, TR_KEY_watch_dir, &dir, nullptr) && !tr_str_is_empty(dir))
{
tr_logAddInfo("Watching \"%s\" for new .torrent files", dir);
if ((watchdir = tr_watchdir_new(dir, &onFileAdded, mySession, ev_base, force_generic)) == nullptr)
watchdir = tr_watchdir_new(dir, &onFileAdded, mySession, ev_base, force_generic);
if (watchdir == nullptr)
{
goto CLEANUP;
}

View File

@ -216,14 +216,14 @@ static void tr_watchdir_retry_restart(tr_watchdir_retry* retry)
***/
tr_watchdir_t tr_watchdir_new(
char const* path,
std::string_view path,
tr_watchdir_cb callback,
void* callback_user_data,
struct event_base* event_base,
bool force_generic)
{
auto* handle = tr_new0(struct tr_watchdir, 1);
handle->path = tr_strdup(path);
handle->path = tr_strvDup(path);
handle->callback = callback;
handle->callback_user_data = callback_user_data;
handle->event_base = event_base;

View File

@ -8,6 +8,8 @@
#pragma once
#include <string_view>
#include "tr-macros.h"
struct event_base;
@ -26,7 +28,7 @@ using tr_watchdir_cb = tr_watchdir_status (*)(tr_watchdir_t handle, char const*
/* ... */
tr_watchdir_t tr_watchdir_new(
char const* path,
std::string_view path,
tr_watchdir_cb callback,
void* callback_user_data,
struct event_base* event_base,