SHARE
TWEET

Transmission Daemon v2.92 watchdir .magnet files support

a guest Mar 7th, 2016 145 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- orig/daemon/daemon.c    2016-02-23 14:22:59.000000000 +1000
  2. +++ new/daemon/daemon.c 2016-03-08 03:08:22.687500000 +1000
  3. @@ -192,12 +192,21 @@ onFileAdded (tr_watchdir_t   dir,
  4.  {
  5.      tr_session * session = context;
  6.  
  7. -    if (!tr_str_has_suffix (name, ".torrent"))
  8. +    if (!tr_str_has_suffix (name, ".torrent") && !tr_str_has_suffix (name, ".magnet"))
  9.          return TR_WATCHDIR_IGNORE;
  10.  
  11.      char * filename = tr_buildPath (tr_watchdir_get_path (dir), name, NULL);
  12.      tr_ctor * ctor = tr_ctorNew (session);
  13. -    int err = tr_ctorSetMetainfoFromFile (ctor, filename);
  14. +    int err;
  15. +    if (tr_str_has_suffix (name, ".torrent"))
  16. +        err = tr_ctorSetMetainfoFromFile (ctor, filename);
  17. +    else {
  18. +        char * link;
  19. +        size_t    len;
  20. +        link = (char*)tr_loadFile (filename, &len, NULL);
  21. +        err = tr_ctorSetMetainfoFromMagnetLink (ctor, link);
  22. +        tr_free(link);
  23. +    }
  24.  
  25.      if (!err)
  26.      {
RAW Paste Data
Top