@type cache_dir: L{twisted.python.filepath.FilePath}
@ivar cache_dir: the directory to use for storing all files
- @type unload_delay: C{int}
- @ivar unload_delay: the time to wait before unloading the apt cache
@type apt_caches: C{dictionary}
@ivar apt_caches: the avaliable mirrors
"""
- def __init__(self, cache_dir, unload_delay):
+ def __init__(self, cache_dir):
self.cache_dir = cache_dir
- self.unload_delay = unload_delay
self.apt_caches = {}
def extractPath(self, url):
if baseDir not in self.apt_caches[site]:
site_cache = self.cache_dir.child(aptpkg_dir).child('mirrors').child(site + baseDir.replace('/', '_'))
site_cache.makedirs
- self.apt_caches[site][baseDir] = AptPackages(site_cache, self.unload_delay)
+ self.apt_caches[site][baseDir] = AptPackages(site_cache)
def updatedFile(self, url, file_path):
"""A file in the mirror has changed or been added.
@return: a deferred that will fire with the returned L{Hash.HashObject}
"""
site, baseDir, path = self.extractPath(url)
+ self.init(site, baseDir)
if site in self.apt_caches and baseDir in self.apt_caches[site]:
return self.apt_caches[site][baseDir].findHash(path)
- d = defer.Deferred()
- d.errback(MirrorError("Site Not Found"))
- return d
+ return defer.fail(MirrorError("Site Not Found"))
def cleanup(self):
for site in self.apt_caches.keys():
client = None
def setUp(self):
- self.client = MirrorManager(FilePath('/tmp/.apt-p2p'), 300)
+ self.client = MirrorManager(FilePath('/tmp/.apt-p2p'))
def test_extractPath(self):
"""Test extracting the site and base directory from various mirrors."""