]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Add cleanup to the MirrorManager for the AptPackages.
authorCameron Dale <camrdale@gmail.com>
Sun, 2 Mar 2008 20:40:17 +0000 (12:40 -0800)
committerCameron Dale <camrdale@gmail.com>
Sun, 2 Mar 2008 20:40:17 +0000 (12:40 -0800)
apt_dht/AptPackages.py
apt_dht/MirrorManager.py

index 48dd4480fd729dc3b31aeb5f7a213f0bffff712f..1cd517a9d378b03abb702a90351cf940c64bbcb2 100644 (file)
@@ -162,7 +162,6 @@ class AptPackages:
         
     def __del__(self):
         self.cleanup()
-        self.packages.close()
         
     def addRelease(self, cache_path, file_path):
         """Dirty hack until python-apt supports apt-pkg/indexrecords.h
@@ -282,6 +281,8 @@ class AptPackages:
     def cleanup(self):
         """Cleanup and close any loaded caches."""
         self.unload()
+        if self.unload_later and self.unload_later.active():
+            self.unload_later.cancel()
         self.packages.close()
         
     def findHash(self, path):
index 738fdebc4d7e668d6dee6e42ee7ce2860c68ceb7..6c417b5cfd0116a7d1b49e147469564ba5678312 100644 (file)
@@ -75,6 +75,13 @@ class MirrorManager:
         d.errback(MirrorError("Site Not Found"))
         return d
     
+    def cleanup(self):
+        for site in self.apt_caches.keys():
+            for baseDir in self.apt_caches[site].keys():
+                self.apt_caches[site][baseDir].cleanup()
+                del self.apt_caches[site][baseDir]
+            del self.apt_caches[site]
+    
 class TestMirrorManager(unittest.TestCase):
     """Unit tests for the mirror manager."""
     
@@ -180,5 +187,6 @@ class TestMirrorManager(unittest.TestCase):
         for p in self.pending_calls:
             if p.active():
                 p.cancel()
+        self.client.cleanup()
         self.client = None
         
\ No newline at end of file