summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbendikro <bro.devel@gmail.com>2016-10-19 10:09:22 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2016-10-19 11:58:03 +0100
commit5394ac56046b232c4cc99eb6962b044a539ad85d (patch)
tree44cd5d8de838a8deb3aeca5645b4f81baa6c50d3
parentf739269dfd0358a37e54b21b319b2618e38f248c (diff)
downloaddeluge-5394ac56046b232c4cc99eb6962b044a539ad85d.tar.gz
deluge-5394ac56046b232c4cc99eb6962b044a539ad85d.tar.bz2
deluge-5394ac56046b232c4cc99eb6962b044a539ad85d.zip
[#2875][Web] Fix: WebUI Json dumps Error
* A torrent file contains an uncommon field 'filehash' which must be hex encoded to allow dumping the torrent info to json. Otherwise it will fail with: UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 0: invalid continuation byte
-rw-r--r--deluge/ui/common.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/deluge/ui/common.py b/deluge/ui/common.py
index 85c8351b1..a3f5a1256 100644
--- a/deluge/ui/common.py
+++ b/deluge/ui/common.py
@@ -110,9 +110,11 @@ class TorrentInfo(object):
f["path"] = path
f["index"] = index
if "sha1" in f and len(f["sha1"]) == 20:
- f["sha1"] = f["sha1"].encode('hex')
+ f["sha1"] = f["sha1"].encode('hex')
if "ed2k" in f and len(f["ed2k"]) == 16:
- f["ed2k"] = f["ed2k"].encode('hex')
+ f["ed2k"] = f["ed2k"].encode('hex')
+ if "filehash" in f and len(f["filehash"]) == 20:
+ f["filehash"] = f["filehash"].encode('hex')
paths[path] = f
dirname = os.path.dirname(path)
while dirname: