Some last few things to do before release.
- Handle/investigate the HTTP client pipeline errors
-- update the modtime of files downloaded from peers
- - also set the Last-Modified header for the return to Apt
Consider what happens when multiple requests for a file are received.
self.compact_peers = compact_peers
self.path = '/~/' + quote_plus(hash.expected())
+ self.defer = None
self.mirror_path = None
self.pieces = None
self.started = False
# self.defer.callback(self.peerlist[0].get(self.path))
# return
- # Start sending the return file
- self.stream = GrowingFileStream(self.file, self.hash.expSize)
- resp = Response(200, {}, self.stream)
- self.defer.callback(resp)
-
# Begin to download the pieces
self.outstanding = 0
self.nextFinish = 0
if response.stream and response.stream.length:
stream.readAndDiscard(response.stream)
else:
+ if self.defer:
+ # Start sending the return file
+ df = self.defer
+ self.defer = None
+ self.stream = GrowingFileStream(self.file, self.hash.expSize)
+
+ # Get the headers from the peer's response
+ headers = {}
+ if response.headers.hasHeader('last-modified'):
+ headers['last-modified'] = response.headers.getHeader('last-modified')
+ resp = Response(200, {}, self.stream)
+ df.callback(resp)
+
# Read the response stream to the file
log.msg('Streaming piece %d from peer %r' % (piece, peer))
if response.code == 206: