projects
/
quix0rs-apt-p2p.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c5ae5c9
)
Add a final retry of all errback mirror downloads.
author
Cameron Dale
<camrdale@gmail.com>
Thu, 24 Apr 2008 23:19:09 +0000
(16:19 -0700)
committer
Cameron Dale
<camrdale@gmail.com>
Thu, 24 Apr 2008 23:19:09 +0000
(16:19 -0700)
apt_p2p/apt_p2p.py
patch
|
blob
|
history
diff --git
a/apt_p2p/apt_p2p.py
b/apt_p2p/apt_p2p.py
index 86bf0132416731e1bc0629b234635e6f817f2132..88e07eaca4948c17f46ff5987666949d978f7dc6 100644
(file)
--- a/
apt_p2p/apt_p2p.py
+++ b/
apt_p2p/apt_p2p.py
@@
-289,6
+289,7
@@
class AptP2P(protocol.Factory):
else:
log.msg('Peers for %s were not found' % url)
getDefer = self.peers.get(hash, url)
else:
log.msg('Peers for %s were not found' % url)
getDefer = self.peers.get(hash, url)
+ getDefer.addErrback(self.final_fallback, hash, url)
getDefer.addCallback(self.cache.save_file, hash, url)
getDefer.addErrback(self.cache.save_error, url)
getDefer.addCallbacks(d.callback, d.errback)
getDefer.addCallback(self.cache.save_file, hash, url)
getDefer.addErrback(self.cache.save_error, url)
getDefer.addCallbacks(d.callback, d.errback)
@@
-306,9
+307,17
@@
class AptP2P(protocol.Factory):
if response.code < 200 or response.code >= 300:
log.msg('Download from peers failed, going to direct download: %s' % url)
getDefer = self.peers.get(hash, url)
if response.code < 200 or response.code >= 300:
log.msg('Download from peers failed, going to direct download: %s' % url)
getDefer = self.peers.get(hash, url)
+ getDefer.addErrback(self.final_fallback, hash, url)
return getDefer
return response
return getDefer
return response
+ def final_fallback(self, err, hash, url):
+ """Final retry if the mirror still generated an error."""
+ log.msg('Download from mirror failed, retrying once only: %s' % url)
+ log.err(err)
+ getDefer = self.peers.get(hash, url)
+ return getDefer
+
def new_cached_file(self, file_path, hash, new_hash, url = None, forceDHT = False):
"""Add a newly cached file to the mirror info and/or the DHT.
def new_cached_file(self, file_path, hash, new_hash, url = None, forceDHT = False):
"""Add a newly cached file to the mirror info and/or the DHT.