[apt-proxy-devel] r583 - people/halls/rework/apt_proxy

Chris Halls halls at costa.debian.org
Mon Sep 12 22:28:55 UTC 2005


Author: halls
Date: Mon Sep 12 22:28:54 2005
New Revision: 583

Modified:
   people/halls/rework/apt_proxy/cache.py
   people/halls/rework/apt_proxy/fetchers.py
Log:
Move a couple more functions into the new Fetcher


Modified: people/halls/rework/apt_proxy/cache.py
==============================================================================
--- people/halls/rework/apt_proxy/cache.py	(original)
+++ people/halls/rework/apt_proxy/cache.py	Mon Sep 12 22:28:54 2005
@@ -219,12 +219,13 @@
 #                 gzip = FetcherGzip()
 #                 gzip.activate(loop, postconverting=1)
 
-    def download_data_rcvd(self, data):
+    def download_data_received(self, data):
         """
         Callback from Fetcher
         A block of data has been received from the streaming backend server
         """
-        pass
+        for req in self.requests:
+            req.write(data)
 
     def download_data_end(self):
         """

Modified: people/halls/rework/apt_proxy/fetchers.py
==============================================================================
--- people/halls/rework/apt_proxy/fetchers.py	(original)
+++ people/halls/rework/apt_proxy/fetchers.py	Mon Sep 12 22:28:54 2005
@@ -41,11 +41,8 @@
         self.init_tempfile()
         self.cacheEntry = cacheEntry
         self.backend = cacheEntry.backend
+        self.len_received = 0
 
-    def getFetcher(self):
-        """
-        get next fetcher for backend
-        """
     def activateNextBackendServer(self, fetcher):
         """
         Returns true if another BackendServer was found
@@ -80,16 +77,37 @@
         to gzip/gunzip file before and after download.
         """
         log.debug("Downloading: " + self.path, 'CacheEntry')
-        self.transfered = TempFile()
+        init_tempfile()
         self.activateNextBackendServer(self.fetcher)
 
     def download_complete(self):
         """
         Download was successful
         """
-        pass
+        self.cacheEntry.download_data_end()
     def download_failed(self):
-        pass
+        self.cacheEntry.download_data_end()
+
+    def cancel_download(self):
+        if self.fetcher and self.fetcher.transport:
+            log.debug(
+                "telling the transport to loseConnection",'Fetcher')
+            try:
+                self.fetcher.transport.loseConnection()
+            except KeyError:
+                # Rsync fetcher already loses conneciton for us
+                pass
+
+    def data_received(self, data):
+        """
+        Data has been received from the backend server
+        """
+        if self.len_received == 0:
+            self.cacheEntry.download_started(self)
+        self.len_received = self.len_received + len(data)
+        if self.transfered:
+            self.transfered.append(data)
+        self.cacheEntry.download_data_received(data)
 
 class FetcherOld:
     """
@@ -114,20 +132,6 @@
         self.status_message = message
         # TODO: notify cacheEntry?
 
-    def cancel_download(self):
-        if self.transport:
-            log.debug(
-                "telling the transport to loseConnection",'Fetcher')
-            try:
-                self.transport.loseConnection()
-            except KeyError:
-                # Rsync fetcher already loses conneciton for us
-                pass
-
-    def start_download(self):
-        log.debug('Start download: %s:%s' % (cacheEntry.backend.name, cacheEntry.path), 'Fetcher')
-        #request.content.read()  -- ??? - no idea what this was for
-
     def apDataReceived(self, data):
         """
         Should be called from the subclasses when data is available for



More information about the apt-proxy-devel mailing list