fixed a rare bug (when you remove the title of the torrent from the URL)

This commit is contained in:
Bora M. Alper 2017-06-16 12:02:24 +03:00
parent 74f5fb6f79
commit 0462d3b8a2

View File

@ -188,8 +188,8 @@ def torrent_redirect(**kwargs):
except (AssertionError, ValueError): # In case info_hash variable is not a proper hex-encoded bytes except (AssertionError, ValueError): # In case info_hash variable is not a proper hex-encoded bytes
return flask.abort(400) return flask.abort(400)
with magnetico_db: with magneticod_db:
cur = magnetico_db.execute("SELECT name FROM torrents WHERE info_hash=? LIMIT 1;", (info_hash,)) cur = magneticod_db.execute("SELECT name FROM torrents WHERE info_hash=? LIMIT 1;", (info_hash,))
try: try:
name = cur.fetchone()[0] name = cur.fetchone()[0]
except TypeError: # In case no results returned, TypeError will be raised when we try to subscript None object except TypeError: # In case no results returned, TypeError will be raised when we try to subscript None object