diff options
author | Jeix <devnull@localhost> | 2011-02-12 10:42:46 +0100 |
---|---|---|
committer | Jeix <devnull@localhost> | 2011-02-12 10:42:46 +0100 |
commit | 2350d53f30de8d45c0f837c8bbdb57b06dece097 (patch) | |
tree | bb6eb6d509f4e9da602689d75f08bc69e510dc3c /module/network/XDCCRequest.py | |
parent | gui optimisations (diff) | |
download | pyload-2350d53f30de8d45c0f837c8bbdb57b06dece097.tar.xz |
xdcc fixes
Diffstat (limited to 'module/network/XDCCRequest.py')
-rw-r--r-- | module/network/XDCCRequest.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/module/network/XDCCRequest.py b/module/network/XDCCRequest.py index 126662bb8..01015cc62 100644 --- a/module/network/XDCCRequest.py +++ b/module/network/XDCCRequest.py @@ -64,7 +64,8 @@ class XDCCRequest(): def download(self, ip, port, filename, progressNotify=None): - lastRecv = time() + lastUpdate = time() + cumRecvLen = 0 dccsock = self.createSocket() @@ -93,13 +94,18 @@ class XDCCRequest(): dataLen = len(data) self.recv += dataLen + cumRecvLen += dataLen + now = time() - timespan = now - lastRecv - if timespan: - self.speed = dataLen / timespan + timespan = now - lastUpdate + if timespan > 1: + self.speed = cumRecvLen / timespan + cumRecvLen = 0 + lastUpdate = now + if progressNotify: progressNotify(self.percent) - lastRecv = now + if not data: break |