From 7f4706b8aa3444a73eac587b317b62b68e2405be Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Sun, 13 Jan 2008 22:58:46 -0800 Subject: [PATCH] Reset the HTTPServer subdirectories when a new cache directory is created. --- apt_dht/CacheManager.py | 3 +++ apt_dht/HTTPServer.py | 1 + apt_dht/apt_dht.py | 1 + 3 files changed, 5 insertions(+) diff --git a/apt_dht/CacheManager.py b/apt_dht/CacheManager.py index 3601619..3789eae 100644 --- a/apt_dht/CacheManager.py +++ b/apt_dht/CacheManager.py @@ -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) diff --git a/apt_dht/HTTPServer.py b/apt_dht/HTTPServer.py index 0e53c23..23f911d 100644 --- a/apt_dht/HTTPServer.py +++ b/apt_dht/HTTPServer.py @@ -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( diff --git a/apt_dht/apt_dht.py b/apt_dht/apt_dht.py index 3679685..1abeaa5 100644 --- a/apt_dht/apt_dht.py +++ b/apt_dht/apt_dht.py @@ -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 -- 2.30.2