Save copies of torrent files from magnet links.

This patch is meant for 1.3-stable (1.3.15 as of the commit date).

The bug is: when you add a new magnet link to download, even if you tick
the option *Copy of .torrent files to:*, deluge still fails to save a
copy of torrent. This patch adds extra code to do so.
This commit is contained in:
Cyker Way 2018-01-20 16:45:33 -05:00 committed by Calum Lind
parent 6c3442e7e7
commit e050905b29
2 changed files with 11 additions and 1 deletions

View file

@ -1,3 +1,8 @@
=== Deluge 1.3.16 (unreleased) ===
==== Core ====
* Fix saving copy of torrent file for magnet links.
=== Deluge 1.3.15 (12 May 2017) ===
==== Core ====

View file

@ -144,7 +144,7 @@ class Torrent(object):
# We store the filename just in case we need to make a copy of the torrentfile
if not filename:
# If no filename was provided, then just use the infohash
filename = self.torrent_id
filename = self.torrent_id + '.torrent'
self.filename = filename
@ -972,6 +972,11 @@ class Torrent(object):
torrent_file["info"] = md
with open(path, "wb") as _file:
_file.write(lt.bencode(torrent_file))
if self.config["copy_torrent_file"]:
config_dir = self.config['torrentfiles_location']
filepath = os.path.join(config_dir, self.filename)
with open(filepath, "wb") as _file:
_file.write(lt.bencode(torrent_file))
except Exception, e:
log.warning("Unable to save torrent file: %s", e)