mirror of
https://github.com/transmission/transmission
synced 2025-02-22 06:00:41 +00:00
refactor: remove tr_variantDictFindStr() from transmission-daemon (#2165)
* refactor: remove tr_variantDictFindStr from transmission-daemon
This commit is contained in:
parent
af8e9e66b9
commit
b1aeaa3dcc
3 changed files with 13 additions and 13 deletions
|
@ -725,19 +725,17 @@ static int daemon_start(void* varg, [[maybe_unused]] bool foreground)
|
||||||
/* maybe add a watchdir */
|
/* maybe add a watchdir */
|
||||||
if (tr_variantDictFindBool(settings, TR_KEY_watch_dir_enabled, &boolVal) && boolVal)
|
if (tr_variantDictFindBool(settings, TR_KEY_watch_dir_enabled, &boolVal) && boolVal)
|
||||||
{
|
{
|
||||||
char const* dir;
|
auto force_generic = bool{ false };
|
||||||
bool force_generic;
|
(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))
|
watchdir = tr_watchdir_new(dir, &onFileAdded, mySession, ev_base, force_generic);
|
||||||
{
|
if (watchdir == nullptr)
|
||||||
tr_logAddInfo("Watching \"%s\" for new .torrent files", dir);
|
|
||||||
|
|
||||||
if ((watchdir = tr_watchdir_new(dir, &onFileAdded, mySession, ev_base, force_generic)) == nullptr)
|
|
||||||
{
|
{
|
||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,14 +216,14 @@ static void tr_watchdir_retry_restart(tr_watchdir_retry* retry)
|
||||||
***/
|
***/
|
||||||
|
|
||||||
tr_watchdir_t tr_watchdir_new(
|
tr_watchdir_t tr_watchdir_new(
|
||||||
char const* path,
|
std::string_view path,
|
||||||
tr_watchdir_cb callback,
|
tr_watchdir_cb callback,
|
||||||
void* callback_user_data,
|
void* callback_user_data,
|
||||||
struct event_base* event_base,
|
struct event_base* event_base,
|
||||||
bool force_generic)
|
bool force_generic)
|
||||||
{
|
{
|
||||||
auto* handle = tr_new0(struct tr_watchdir, 1);
|
auto* handle = tr_new0(struct tr_watchdir, 1);
|
||||||
handle->path = tr_strdup(path);
|
handle->path = tr_strvDup(path);
|
||||||
handle->callback = callback;
|
handle->callback = callback;
|
||||||
handle->callback_user_data = callback_user_data;
|
handle->callback_user_data = callback_user_data;
|
||||||
handle->event_base = event_base;
|
handle->event_base = event_base;
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
#include "tr-macros.h"
|
#include "tr-macros.h"
|
||||||
|
|
||||||
struct event_base;
|
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(
|
tr_watchdir_t tr_watchdir_new(
|
||||||
char const* path,
|
std::string_view path,
|
||||||
tr_watchdir_cb callback,
|
tr_watchdir_cb callback,
|
||||||
void* callback_user_data,
|
void* callback_user_data,
|
||||||
struct event_base* event_base,
|
struct event_base* event_base,
|
||||||
|
|
Loading…
Reference in a new issue