Changeset 14674
- Timestamp:
- Jan 25, 2016, 9:48:58 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/daemon.c
r14651 r14674 560 560 561 561 /* maybe add a watchdir */ 562 if (tr_variantDictFindBool (settings, TR_KEY_watch_dir_enabled, &boolVal) && boolVal) 562 563 { 563 564 const char * dir; 564 565 565 if (tr_variantDictFindBool (settings, TR_KEY_watch_dir_enabled, &boolVal) 566 && boolVal 567 && tr_variantDictFindStr (settings, TR_KEY_watch_dir, &dir, NULL) 568 && dir 569 && *dir) 566 if (tr_variantDictFindStr (settings, TR_KEY_watch_dir, &dir, NULL) && dir != NULL && *dir != '\0') 570 567 { 571 568 tr_logAddInfo ("Watching \"%s\" for new .torrent files", dir); 572 if ((watchdir = tr_watchdir_new (dir, &onFileAdded, mySession, ev_base )) == NULL)569 if ((watchdir = tr_watchdir_new (dir, &onFileAdded, mySession, ev_base, false)) == NULL) 573 570 goto cleanup; 574 571 } -
trunk/libtransmission/CMakeLists.txt
r14661 r14674 260 260 set(crypto-test_ADD_SOURCES crypto-test-ref.h) 261 261 262 set(watchdir@generic-test_DEFINITIONS WATCHDIR_TEST_FORCE_GENERIC) 263 262 264 foreach(T bitfield blocklist clients crypto error file history json magnet metainfo move peer-msgs quark rename rpc session 263 tr-getopt utils variant watchdir )265 tr-getopt utils variant watchdir watchdir@generic) 264 266 set(TP ${TR_NAME}-test-${T}) 265 add_executable(${TP} ${T}-test.c ${${T}-test_ADD_SOURCES}) 267 if(T MATCHES "^([^@]+)@.+$") 268 string(REPLACE "@" "_" TP "${TP}") 269 set(${TP}_TEST_BASENAME "${CMAKE_MATCH_1}") 270 else() 271 set(${TP}_TEST_BASENAME "${T}") 272 endif() 273 add_executable(${TP} ${${TP}_TEST_BASENAME}-test.c ${${T}-test_ADD_SOURCES}) 266 274 target_link_libraries(${TP} ${TR_NAME} ${TR_NAME}-test) 275 if(DEFINED ${T}-test_DEFINITIONS) 276 target_compile_definitions(${TP} PRIVATE ${${T}-test_DEFINITIONS}) 277 endif() 267 278 add_test(NAME ${T} COMMAND ${TP}) 268 279 set_property(TARGET ${TP} PROPERTY FOLDER "UnitTests") -
trunk/libtransmission/Makefile.am
r14660 r14674 189 189 utils-test \ 190 190 variant-test \ 191 watchdir-test 191 watchdir-test \ 192 watchdir-generic-test 192 193 193 194 noinst_PROGRAMS = $(TESTS) … … 290 291 watchdir_test_LDFLAGS = ${apps_ldflags} 291 292 293 watchdir_generic_test_SOURCES = watchdir-test.c $(TEST_SOURCES) 294 watchdir_generic_test_LDADD = ${apps_ldadd} 295 watchdir_generic_test_LDFLAGS = ${apps_ldflags} 296 watchdir_generic_test_CPPFLAGS = -DWATCHDIR_TEST_FORCE_GENERIC $(AM_CPPFLAGS) 297 292 298 rename_test_SOURCES = rename-test.c $(TEST_SOURCES) 293 299 rename_test_LDADD = ${apps_ldadd} -
trunk/libtransmission/watchdir-test.c
r14651 r14674 98 98 } 99 99 100 tr_watchdir_t 101 create_watchdir (const char * path, 102 tr_watchdir_cb callback, 103 void * callback_user_data, 104 struct event_base * event_base) 105 { 106 #ifdef WATCHDIR_TEST_FORCE_GENERIC 107 const bool force_generic = true; 108 #else 109 const bool force_generic = false; 110 #endif 111 112 return tr_watchdir_new (path, callback, callback_user_data, event_base, force_generic); 113 } 114 100 115 /*** 101 116 **** … … 110 125 ev_base = event_base_new(); 111 126 112 wd = tr_watchdir_new(test_dir, &callback, NULL, ev_base);127 wd = create_watchdir (test_dir, &callback, NULL, ev_base); 113 128 check (wd != NULL); 114 129 check (tr_sys_path_is_same (test_dir, tr_watchdir_get_path (wd), NULL)); … … 137 152 reset_callback_data (&wd_data, TR_WATCHDIR_ACCEPT); 138 153 139 tr_watchdir_t wd = tr_watchdir_new(test_dir, &callback, &wd_data, ev_base);154 tr_watchdir_t wd = create_watchdir (test_dir, &callback, &wd_data, ev_base); 140 155 check (wd != NULL); 141 156 … … 154 169 reset_callback_data (&wd_data, TR_WATCHDIR_ACCEPT); 155 170 156 tr_watchdir_t wd = tr_watchdir_new(test_dir, &callback, &wd_data, ev_base);171 tr_watchdir_t wd = create_watchdir (test_dir, &callback, &wd_data, ev_base); 157 172 check (wd != NULL); 158 173 … … 185 200 186 201 reset_callback_data (&wd_data, TR_WATCHDIR_ACCEPT); 187 wd = tr_watchdir_new(test_dir, &callback, &wd_data, ev_base);202 wd = create_watchdir (test_dir, &callback, &wd_data, ev_base); 188 203 check (wd != NULL); 189 204 … … 240 255 241 256 reset_callback_data (&wd1_data, TR_WATCHDIR_ACCEPT); 242 wd1 = tr_watchdir_new(dir1, &callback, &wd1_data, ev_base);257 wd1 = create_watchdir (dir1, &callback, &wd1_data, ev_base); 243 258 check (wd1 != NULL); 244 259 245 260 reset_callback_data (&wd2_data, TR_WATCHDIR_ACCEPT); 246 wd2 = tr_watchdir_new(dir2, &callback, &wd2_data, ev_base);261 wd2 = create_watchdir (dir2, &callback, &wd2_data, ev_base); 247 262 check (wd2 != NULL); 248 263 … … 348 363 349 364 reset_callback_data (&wd_data, TR_WATCHDIR_RETRY); 350 wd = tr_watchdir_new(test_dir, &callback, &wd_data, ev_base);365 wd = create_watchdir (test_dir, &callback, &wd_data, ev_base); 351 366 check (wd != NULL); 352 367 -
trunk/libtransmission/watchdir.c
r14651 r14674 233 233 tr_watchdir_cb callback, 234 234 void * callback_user_data, 235 struct event_base * event_base) 235 struct event_base * event_base, 236 bool force_generic) 236 237 { 237 238 tr_watchdir_t handle; … … 244 245 tr_watchdir_retries_init (&handle->active_retries); 245 246 247 if (!force_generic) 248 { 246 249 #ifdef WITH_INOTIFY 247 if (handle->backend == NULL)248 handle->backend = tr_watchdir_inotify_new (handle);250 if (handle->backend == NULL) 251 handle->backend = tr_watchdir_inotify_new (handle); 249 252 #endif 250 253 #ifdef WITH_KQUEUE 251 if (handle->backend == NULL)252 handle->backend = tr_watchdir_kqueue_new (handle);254 if (handle->backend == NULL) 255 handle->backend = tr_watchdir_kqueue_new (handle); 253 256 #endif 254 257 #ifdef _WIN32 255 if (handle->backend == NULL)256 handle->backend = tr_watchdir_win32_new (handle);258 if (handle->backend == NULL) 259 handle->backend = tr_watchdir_win32_new (handle); 257 260 #endif 261 } 258 262 259 263 if (handle->backend == NULL) -
trunk/libtransmission/watchdir.h
r14651 r14674 36 36 tr_watchdir_cb callback, 37 37 void * callback_user_data, 38 struct event_base * event_base); 38 struct event_base * event_base, 39 bool force_generic); 39 40 40 41 void tr_watchdir_free (tr_watchdir_t handle);
Note: See TracChangeset
for help on using the changeset viewer.