Advertisement
Guest User

Untitled

a guest
Oct 13th, 2014
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. diff -rupN orig2/daemon/daemon.c orig/daemon/daemon.c
  2. --- orig2/daemon/daemon.c 2014-10-13 22:24:47.619262656 +0300
  3. +++ orig/daemon/daemon.c 2014-10-13 22:24:59.835910372 +0300
  4. @@ -264,7 +264,16 @@ onFileAdded (tr_session * session, const
  5. {
  6. char * filename = tr_buildPath (dir, file, NULL);
  7. tr_ctor * ctor = tr_ctorNew (session);
  8. - int err = tr_ctorSetMetainfoFromFile (ctor, filename);
  9. + int err;
  10. + if (tr_str_has_suffix (file, ".torrent"))
  11. + err = tr_ctorSetMetainfoFromFile (ctor, filename);
  12. + else {
  13. + char * link;
  14. + size_t len;
  15. + link = (char*)tr_loadFile (filename,&len);
  16. + err = tr_ctorSetMetainfoFromMagnetLink (ctor, link);
  17. + tr_free(link);
  18. + }
  19.  
  20. if (!err)
  21. {
  22. diff -rupN orig2/daemon/watch.c orig/daemon/watch.c
  23. --- orig2/daemon/watch.c 2014-10-13 22:24:47.619262656 +0300
  24. +++ orig/daemon/watch.c 2014-10-13 22:25:06.229233796 +0300
  25. @@ -85,7 +85,7 @@ watchdir_new_impl (dtr_watchdir * w)
  26. {
  27. const char * name = d->d_name;
  28.  
  29. - if (!tr_str_has_suffix (name, ".torrent")) /* skip non-torrents */
  30. + if (!tr_str_has_suffix (name, ".torrent") && !tr_str_has_suffix (name, ".magnet") ) /* skip non-torrents */
  31. continue;
  32.  
  33. tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
  34. @@ -135,7 +135,7 @@ watchdir_update_impl (dtr_watchdir * w)
  35. while (i < len) {
  36. struct inotify_event * event = (struct inotify_event *) &buf[i];
  37. const char * name = event->name;
  38. - if (tr_str_has_suffix (name, ".torrent"))
  39. + if (tr_str_has_suffix (name, ".torrent") || tr_str_has_suffix (name, ".magnet") )
  40. {
  41. tr_logAddInfo ("Found new .torrent file \"%s\" in watchdir \"%s\"", name, w->dir);
  42. w->callback (w->session, w->dir, name);
  43. @@ -216,7 +216,7 @@ watchdir_update_impl (dtr_watchdir * w)
  44.  
  45. if (!name || *name=='.') /* skip dotfiles */
  46. continue;
  47. - if (!tr_str_has_suffix (name, ".torrent")) /* skip non-torrents */
  48. + if (!tr_str_has_suffix (name, ".torrent") && !tr_str_has_suffix (name, ".magnet") ) /* skip non-torrents */
  49. continue;
  50.  
  51. len = strlen (name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement