From e050905b291f4d9b417270e38f2aa04366057919 Mon Sep 17 00:00:00 2001 From: Cyker Way Date: Sat, 20 Jan 2018 16:45:33 -0500 Subject: 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. --- ChangeLog | 5 +++++ deluge/core/torrent.py | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 43b5827d3..2899003ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 ==== diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 6e1727a59..8b18ee147 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -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) -- cgit