[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.
This commit is contained in:
parent
8a3f15e5c0
commit
b52de1549e
|
@ -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:
|
||||
|
|
|
@ -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,7 +197,9 @@ class Core(CorePluginBase):
|
|||
|
||||
for part in magnet.split('&'):
|
||||
if part.startswith("dn="):
|
||||
mname = os.sep.join([path, part[3:] + ".magnet"])
|
||||
name = part[3:].strip()
|
||||
if name:
|
||||
mname = os.sep.join([path, name + ".magnet"])
|
||||
break
|
||||
else:
|
||||
short_hash = magnet.split("btih:")[1][:8]
|
||||
|
|
|
@ -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."
|
||||
|
|
Loading…
Reference in New Issue