Skip to content

Commit

Permalink
Fix deluge sending ratio -1 when it shouldn't send anything
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandog committed May 14, 2016
1 parent 279811d commit 0895100
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion sickbeard/clients/deluge_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,17 @@ def _set_torrent_ratio(self, result):
if result.ratio:
ratio = result.ratio

if ratio:
# blank is default client ratio, so we also shouldn't set ratio
if ratio and float(ratio) >= 0:
post_data = json.dumps({"method": "core.set_torrent_stop_at_ratio",
"params": [result.hash, True],
"id": 5})

self._request(method='post', data=post_data)

# Return false if we couldn't enable setting set_torrent_stop_at_ratio. No reason to set ratio.
if self.response.json()['error']:
return False

post_data = json.dumps({"method": "core.set_torrent_stop_ratio",
"params": [result.hash, float(ratio)],
Expand All @@ -182,6 +187,17 @@ def _set_torrent_ratio(self, result):

return not self.response.json()['error']

elif ratio and float(ratio) == -1:
# Disable stop at ratio to seed forever
post_data = json.dumps({"method": "core.set_torrent_stop_at_ratio",
"params": [result.hash, False],
"id": 5})

self._request(method='post', data=post_data)

return not self.response.json()['error']


return True

def _set_torrent_path(self, result):
Expand Down

0 comments on commit 0895100

Please sign in to comment.