Reset the HTTPServer subdirectories when a new cache directory is created.
authorCameron Dale <camrdale@gmail.com>
Mon, 14 Jan 2008 06:58:46 +0000 (22:58 -0800)
committerCameron Dale <camrdale@gmail.com>
Mon, 14 Jan 2008 06:58:46 +0000 (22:58 -0800)
apt_dht/CacheManager.py
apt_dht/HTTPServer.py
apt_dht/apt_dht.py

index 3601619..3789eae 100644 (file)
@@ -206,6 +206,9 @@ class CacheManager:
                 
             urlpath, newdir = self.db.storeFile(destFile, hash.digest(), self.cache_dir)
             log.msg('now avaliable at %s: %s' % (urlpath, url))
+            if newdir and self.manager:
+                log.msg('A new web directory was created, so enable it')
+                self.manager.setDirectories(self.db.getAllDirectories())
 
             if self.manager:
                 self.manager.new_cached_file(url, destFile, hash, urlpath)
index 0e53c23..23f911d 100644 (file)
@@ -51,6 +51,7 @@ class TopLevel(resource.Resource):
             # Don't allow empty subdirectory
             if k:
                 self.subdirs[k] = dirs[k]
+        log.msg('new subdirectories initialized')
     
     def render(self, ctx):
         return http.Response(
index 3679685..1abeaa5 100644 (file)
@@ -35,6 +35,7 @@ class AptDHT:
         self.mirrors = MirrorManager(self.cache_dir)
         self.cache = CacheManager(self.cache_dir.child(download_dir), self.db, self)
         self.my_addr = None
+        self.setDirectories = self.http_server.setDirectories
     
     def getSite(self):
         return self.http_site