linuxvpsbittorrentjson-rpcaria2

The aria2.addTorrent method in aria2c's RPC interface ignores "dir" option


I am using aria2c as a daemon (the RPC interface) on a server, and when I use aria2.addTorrent method to add a torrent + a specific directory where the files have to be downloaded, aria2c downloads the file but not in the directory that I specified

This is how I am running the daemon:

aria2c --log="the.log" --disable-ipv6 \
--enable-rpc --rpc-listen-all --rpc-listen-port=7777 \
--seed-time=0 --bt-tracker-connect-timeout=30 --bt-tracker-timeout=10

And this is the data (as a JSON) that I am sending to the aria2c server locally:

{
    "jsonrpc":"2.0",
    "id":user_id,
    "method":"aria2.addTorrent",
    "params":[mfile_base64,[{"dir":outdir_str}]],
}

# user_id = Some random username or id
# mfile_base64 = Base64 encoded contents of the metafile (the .torrent file)
# outdir_str = The directory were I want the file(s) to be downloaded

And again, the file is downloaded correctly but not in the directory that I want: It is being downloaded in my Current Working Directory

And in case someone asks, my read/write access is fine, the directory exists before the download even starts, it is a normal directory, it's not a mountpoint to another partition or any other resource over a network, etc... etc... etc...

EDIT 1

# I tried this:
{
    "jsonrpc":"2.0",
    "id":user_id,
    "method":"aria2.addTorrent",
    "params":[mfile_base64,{"dir":outdir_str}],
}

# And the download does not even start, it throws an error, this is the JSON response:
{'id': 'user1', 'jsonrpc': '2.0', 'error': {'code': 1, 'message': 'The parameter at 1 has wrong type.'}}


Solution

  • FIXED IT

    There was a missing element in the params list: the URIs list In my case, I left it empty since i got nothing to put in there

    {
        "jsonrpc":"2.0",
        "id":user_id,
        "method":"aria2.addTorrent",
        "params":[mfile_base64,[],{"dir":outdir_str}],
    }
    

    And it works: the options dict is no longer ignored and therefore, the files are downloaded in the directory that I want