diff --git a/addon.xml b/addon.xml index 2ad983b..64184ad 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/lib/pyrrent2http/engine.py b/lib/pyrrent2http/engine.py index 210de6d..7d4b573 100644 --- a/lib/pyrrent2http/engine.py +++ b/lib/pyrrent2http/engine.py @@ -247,6 +247,11 @@ class Engine: def activate_file(self, index): self.pyrrent2http.TorrentFS.file(index) + + def pause(self): + self.pyrrent2http.pause = True + def resume(self): + self.pyrrent2http.pause = False def check_torrent_error(self, status=None): """ diff --git a/lib/pyrrent2http/pyrrent2http.py b/lib/pyrrent2http/pyrrent2http.py index 59f290e..0abe6a9 100644 --- a/lib/pyrrent2http/pyrrent2http.py +++ b/lib/pyrrent2http/pyrrent2http.py @@ -412,6 +412,9 @@ def HttpHandlerFactory(): buf = bytearray(chunk) try: if f.Read(buf) < 1: break + while self.server.root_obj.pause: + time.sleep(0.1) + continue self.wfile.write(buf) except: break @@ -461,6 +464,7 @@ def HttpHandlerFactory(): return HttpHandler class Pyrrent2http(object): + pause = False def __init__(self, uri = '', bindAddress = 'localhost:5001', downloadPath = '.', idleTimeout = -1, keepComplete = False, keepIncomplete = False, keepFiles = False, showAllStats = False,