X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=apt_p2p%2FMirrorManager.py;h=f91db7647459d05ec40c8a4c066bfb943e382080;hb=c749275a35e84d45ea694f9dc90a89df09caf1b2;hp=4c19f1070afb66e49d53250251342dad2a845e11;hpb=7b1167d8ce780312d3689c9309c7e9c64060c085;p=quix0rs-apt-p2p.git diff --git a/apt_p2p/MirrorManager.py b/apt_p2p/MirrorManager.py index 4c19f10..f91db76 100644 --- a/apt_p2p/MirrorManager.py +++ b/apt_p2p/MirrorManager.py @@ -25,15 +25,12 @@ class MirrorManager: @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): @@ -93,7 +90,7 @@ class MirrorManager: 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. @@ -112,11 +109,10 @@ class MirrorManager: @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(): @@ -133,7 +129,7 @@ class TestMirrorManager(unittest.TestCase): 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."""