Fix some documentation errors.
[quix0rs-apt-p2p.git] / apt_p2p / apt_p2p.py
index 86bf0132416731e1bc0629b234635e6f817f2132..385e27571226a2c8f32571bac3b39b46b205c95b 100644 (file)
@@ -179,8 +179,6 @@ class AptP2P(protocol.Factory):
         @param url: the URI of the actual mirror request
         @type orig_resp: L{twisted.web2.http.Response}
         @param orig_resp: the response from the cache to be sent to apt
-        @rtype: L{twisted.internet.defer.Deferred}
-        @return: a deferred that will be called back with the correct response
         """
         log.msg('Checking if %s is still fresh' % url)
         modtime = orig_resp.headers.getHeader('Last-Modified')
@@ -289,6 +287,7 @@ class AptP2P(protocol.Factory):
             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)
@@ -306,9 +305,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)
+#            getDefer.addErrback(self.final_fallback, hash, url)
             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.