I've been having some trouble with adding torrents by URL through the webui. When a torrent is added this way, deluged tries to first download the torrent file to its current working directory and then adds the torrent. Since I'm running this on a headless Lucid server with deluged being started by the Deluge init script, its working directory is the root (/) directory; my understanding is this is the nature of starting a process with start-stop-daemon. Because I'm not willing to give the deluge user write permissions to the root directory, adding a torrent this way fails every time.
Digging a little deeper, in the add_torrent_url function in core.py, the download filename is simply the filename from the URL (the substring after the last '/' in the URL, ie 'download.torrent' in 'http://foo/bar/download.torrent'), with no additional path given. While I know next to nothing about Python, I would imagine this would cause it to default to a relative path, thus explaining the aforementioned problem. I've worked around this by prefixing filename parameter in the download_file function call with my desired torrent file download path, and, viola, it works. This, of course, is not ideal since it will break again with the next update.
Am I missing something here? I've searched and searched and searched and haven't found anyone else mentioning anything about it, so I'm thinking I'm doing something wrong. Is there someway to set the torrent file download path or change the current working directory? Any input would be greatly appreciated. Thanks!
deluged Working Directory
Re: deluged Working Directory
You can change the default download location by going to Preferences, selecting Downloads (should be the first page in the web UI) and changing "Download to".
Re: deluged Working Directory
It's not the download location - I can download torrents just fine when I add them via other means - it's the torrent-file download location I'm having trouble with. When you add a torrent by URL using the webui, deluged first fetches the torrent-file, saves it to some location, and then adds it to the queue. So where is it being saved? It is not the same directory as the 'download to' directory; at least that is not what I'm experiencing. Should these torrent files be saved to the download directory?
Looking at the code, it appears it is saving it to the working directory (it is being saved as 'foo.torrent' instead of '/some/path/to/foo.torrent') If you're running this as a regular user in a desktop environment, this would probably be your home directory, but when run using start-stop-daemon (as with the init script), this is the root directory.
I changed the respective function call in add_torrent_url to save the torrent to /tmp/ and it now works as expected. On line 250 in deluge/core/core.py, I changed:
to:
and all is now right in the world.
Oh, and this is with 1.2.3.
Looking at the code, it appears it is saving it to the working directory (it is being saved as 'foo.torrent' instead of '/some/path/to/foo.torrent') If you're running this as a regular user in a desktop environment, this would probably be your home directory, but when run using start-stop-daemon (as with the init script), this is the root directory.
I changed the respective function call in add_torrent_url to save the torrent to /tmp/ and it now works as expected. On line 250 in deluge/core/core.py, I changed:
Code: Select all
d = download_file(url, url.split("/")[-1], headers=headers)
Code: Select all
d = download_file(url, "/tmp/" + url.split("/")[-1], headers=headers)
Oh, and this is with 1.2.3.
Re: deluged Working Directory
Thanks, I've fixed that in master and it will be in 1.3.
However it still doesn't explain how changing add_torrent_url solved your problem as the web UI doesn't use add_torrent_url.
However it still doesn't explain how changing add_torrent_url solved your problem as the web UI doesn't use add_torrent_url.
Re: deluged Working Directory
It doesn't really have anything to do with the web UI directly, just that using it to add a torrent by URL causes deluged to call this function. I'm guessing that adding a torrent by URL with the GTK UI causes the torrent to be downloaded locally and then added to the daemon just like any other torrent, thus not causing a problem.
Re: deluged Working Directory
Yes, adding a torrent by URL through the GTK UI or Web UI first downloads the torrent (so that it can display the filenames and allow you to change them) and then adds the torrent file manually.
I'm guessing you're using some external program/script to directly add the torrents via URL?
I'm guessing you're using some external program/script to directly add the torrents via URL?