Deluge is a good software. However, recently I was plagued by a bug in its latest stable version 1.3.15: It simply doesn’t save torrent files when they are added via magnet links.

After some research it shows this is actually an old problem that has been tackled by its engineers:

However, for whatever reason, this commit is not included in its stable branch. It does get included in the master and develop branch. But as the code base evolves, this commit no longers applies to the tip of the current stable branch. So it’s not as easy as grab the change and paste it in.

After some more research, I made this patch that should fix this bug for version 1.3.15. After this patch is applied, uploaded torrent files will be copied as usual, and magnet converted torrent files will be copied into files named by their torrent ID (the hash). Note that there is no .torrent suffix for magnet torrent files because of how deluge works internally.

To use this patch on Ubuntu 16.04, download the patch into an empty dir, cd into the dir and run this script:

#!/bin/bash
apt-get download deluge-common
mkdir pkg
dpkg-deb -R deluge-common_1.3.15-1~xenial~ppa3_all.deb pkg
rm deluge-common_1.3.15-1~xenial~ppa3_all.deb
cd pkg/usr/lib/python2.7/dist-packages
patch -p1 < ../../../../../fix-magnet-saving.patch
cd -
dpkg-deb -b pkg deluge-common_1.3.15-1~xenial~ppa3_all.deb
apt-get install --reinstall ./deluge-common_1.3.15-1~xenial~ppa3_all.deb

Note that this package is not from the default Ubuntu repo, but the official deluge ppa:

sudo add-apt-repository ppa:deluge-team/ppa
sudo apt-get update
sudo apt-get install deluge

You may also directly download and install the patched package: