From: Cameron Dale Date: Mon, 14 Jan 2008 06:58:46 +0000 (-0800) Subject: Reset the HTTPServer subdirectories when a new cache directory is created. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7f4706b8aa3444a73eac587b317b62b68e2405be;p=quix0rs-apt-p2p.git Reset the HTTPServer subdirectories when a new cache directory is created. --- 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