summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Jeix <devnull@localhost> 2012-02-05 15:53:40 +0100
committerGravatar Jeix <devnull@localhost> 2012-02-05 15:53:40 +0100
commitf631eda05ca45b7b503bb26aca746d735165d308 (patch)
tree92d087034eefd501bbdd875001d3e337a40ab99e /module
parentTreat most errors as tempfailures, this will solve the missing errors. (diff)
downloadpyload-f631eda05ca45b7b503bb26aca746d735165d308.tar.xz
xdcc fix
Diffstat (limited to 'module')
-rw-r--r--module/network/XDCCRequest.py21
-rw-r--r--module/plugins/hoster/Xdcc.py3
2 files changed, 20 insertions, 4 deletions
diff --git a/module/network/XDCCRequest.py b/module/network/XDCCRequest.py
index 92ccb4839..f03798c17 100644
--- a/module/network/XDCCRequest.py
+++ b/module/network/XDCCRequest.py
@@ -63,8 +63,9 @@ class XDCCRequest():
return socket.socket()
- def download(self, ip, port, filename, progressNotify=None):
+ def download(self, ip, port, filename, irc, progressNotify=None):
+ ircbuffer = ""
lastUpdate = time()
cumRecvLen = 0
@@ -94,6 +95,8 @@ class XDCCRequest():
remove(filename)
raise Abort()
+ self._keepAlive(irc, ircbuffer)
+
data = dccsock.recv(4096)
dataLen = len(data)
self.recv += dataLen
@@ -124,7 +127,21 @@ class XDCCRequest():
return filename
-
+ def _keepAlive(self, sock, readbuffer):
+ fdset = select([sock], [], [], 0)
+ if sock not in fdset[0]:
+ return
+
+ readbuffer += sock.recv(1024)
+ temp = readbuffer.split("\n")
+ readbuffer = temp.pop()
+
+ for line in temp:
+ line = line.rstrip()
+ first = line.split()
+ if first[0] == "PING":
+ sock.send("PONG %s\r\n" % first[1])
+
def abortDownloads(self):
self.abort = True
diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py
index 7d83b050c..6f0a1b176 100644
--- a/module/plugins/hoster/Xdcc.py
+++ b/module/plugins/hoster/Xdcc.py
@@ -215,7 +215,7 @@ class Xdcc(Hoster):
self.log.info("XDCC: Downloading %s from %s:%d" % (packname, ip, port))
self.pyfile.setStatus("downloading")
- newname = self.req.download(ip, port, filename, self.pyfile.setProgress)
+ newname = self.req.download(ip, port, filename, sock, self.pyfile.setProgress)
if newname and newname != filename:
self.log.info("%(name)s saved as %(newname)s" % {"name": self.pyfile.name, "newname": newname})
filename = newname
@@ -227,4 +227,3 @@ class Xdcc(Hoster):
self.lastDownload = filename
return self.lastDownload
-