summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2017-02-15 23:30:53 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2017-02-15 23:33:28 +0000
commitb52de1549eb8dd8297d9c603a7faa1b58d647daf (patch)
tree2aa76ccc5339cb7c2f858c279b463a7abc9501d3
parent8a3f15e5c0a3fbd14840d6e6954dc4c1e07ddc6f (diff)
downloaddeluge-b52de1549eb8dd8297d9c603a7faa1b58d647daf.tar.gz
deluge-b52de1549eb8dd8297d9c603a7faa1b58d647daf.tar.bz2
deluge-b52de1549eb8dd8297d9c603a7faa1b58d647daf.zip
[Core] Fix adding magnet with trailing newline
* A bug in libtorrent means that a magnet with a trailing newline will be added but with an invalid info_hash. Strip any whitespace before add is a workaround.
-rw-r--r--deluge/core/torrentmanager.py3
-rw-r--r--deluge/plugins/autoadd/autoadd/core.py8
-rw-r--r--deluge/plugins/autoadd/setup.py2
3 files changed, 8 insertions, 5 deletions
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index abd35e328..a5c3620cc 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -471,7 +471,8 @@ class TorrentManager(component.Component):
handle = None
try:
if magnet:
- handle = lt.add_magnet_uri(self.session, utf8_encoded(magnet), add_torrent_params)
+ magnet_uri = utf8_encoded(magnet.strip())
+ handle = lt.add_magnet_uri(self.session, magnet_uri, add_torrent_params)
else:
handle = self.session.add_torrent(add_torrent_params)
except RuntimeError, e:
diff --git a/deluge/plugins/autoadd/autoadd/core.py b/deluge/plugins/autoadd/autoadd/core.py
index 53c557598..adbc66ec5 100644
--- a/deluge/plugins/autoadd/autoadd/core.py
+++ b/deluge/plugins/autoadd/autoadd/core.py
@@ -163,7 +163,7 @@ class Core(CorePluginBase):
_file = open(filename, "rb")
elif magnet == True:
_file = open(filename, "r")
- filedump = _file.read()
+ filedump = _file.read().strip()
if not filedump:
raise RuntimeError, "Torrent is 0 bytes!"
_file.close()
@@ -197,8 +197,10 @@ class Core(CorePluginBase):
for part in magnet.split('&'):
if part.startswith("dn="):
- mname = os.sep.join([path, part[3:] + ".magnet"])
- break
+ name = part[3:].strip()
+ if name:
+ mname = os.sep.join([path, name + ".magnet"])
+ break
else:
short_hash = magnet.split("btih:")[1][:8]
mname = '.'.join([filename, short_hash, "magnet"])
diff --git a/deluge/plugins/autoadd/setup.py b/deluge/plugins/autoadd/setup.py
index de759fab7..96e811834 100644
--- a/deluge/plugins/autoadd/setup.py
+++ b/deluge/plugins/autoadd/setup.py
@@ -42,7 +42,7 @@ from setuptools import setup
__plugin_name__ = "AutoAdd"
__author__ = "Chase Sterling"
__author_email__ = "chase.sterling@gmail.com"
-__version__ = "1.04"
+__version__ = "1.05"
__url__ = "http://dev.deluge-torrent.org/wiki/Plugins/AutoAdd"
__license__ = "GPLv3"
__description__ = "Monitors folders for .torrent files."