Skip to content

Commit

Permalink
watch: can use .magnet files
Browse files Browse the repository at this point in the history
  • Loading branch information
piec committed Aug 12, 2020
1 parent 8fcfc1e commit 6be3f51
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions daemon/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,28 @@ static tr_watchdir_status onFileAdded(tr_watchdir_t dir, char const* name, void*
{
tr_session* session = context;

if (!tr_str_has_suffix(name, ".torrent"))
if (!tr_str_has_suffix(name, ".torrent") && !tr_str_has_suffix(name, ".magnet"))
{
return TR_WATCHDIR_IGNORE;
}

char* filename = tr_buildPath(tr_watchdir_get_path(dir), name, NULL);
tr_ctor* ctor = tr_ctorNew(session);
int err = tr_ctorSetMetainfoFromFile(ctor, filename);
int err;
if (tr_str_has_suffix(name, ".torrent"))
{
err = tr_ctorSetMetainfoFromFile(ctor, filename);
}
else
{
size_t len;
uint8_t* link = tr_loadFile(filename, &len, NULL);
if (link != NULL)
{
err = tr_ctorSetMetainfoFromMagnetLink(ctor, link);
tr_free(link);
}
}

if (err == 0)
{
Expand Down

0 comments on commit 6be3f51

Please sign in to comment.