Some last few things to do before release.
- Handle/investigate the HTTP client pipeline errors
-- remove files from the peer's download cache
- update the modtime of files downloaded from peers
- also set the Last-Modified header for the return to Apt
import sha
from twisted.internet import reactor, defer
-from twisted.python import log
+from twisted.python import log, filepath
from twisted.trial import unittest
from twisted.web2 import stream
from twisted.web2.http import Response, splitHostPort
deferred.callback(b)
else:
# We're done
+ self._close()
deferred = self.deferred
self.deferred = None
deferred.callback(None)
else:
# We're done
+ self._close()
deferred = self.deferred
self.deferred = None
deferred.callback(None)
# If we don't have any available, we're done or deferred
if readSize <= 0:
if self.finished:
+ self._close()
return None
else:
self.deferred = defer.Deferred()
if not bytesRead:
# End of file was reached, we're done or deferred
if self.finished:
+ self._close()
return None
else:
self.deferred = defer.Deferred()
self.position += bytesRead
return b
+ def _close(self):
+ """Close the temporary file and remove it."""
+ self.f.close()
+ filepath.FilePath(self.f.name).remove()
+ self.f = None
+
class StreamToFile:
"""Save a stream to a partial file and hash it.