diff options
author | Clark Williams <williams@redhat.com> | 2008-02-29 16:27:05 -0600 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2008-02-29 16:27:05 -0600 |
commit | 8a37cad09df6b41032e5d1b79995b1c391bb2882 (patch) | |
tree | cf2454064c04a681f8ff8384eeafc32e53eb7f71 /py/mock | |
parent | 62b7b91c0f1d71f903f7bd81403a29f8d943bbaf (diff) | |
download | mock-8a37cad09df6b41032e5d1b79995b1c391bb2882.tar.gz mock-8a37cad09df6b41032e5d1b79995b1c391bb2882.tar.xz mock-8a37cad09df6b41032e5d1b79995b1c391bb2882.zip |
modify rootcache logic to rebuild cache if config files have newer timestamp
Diffstat (limited to 'py/mock')
-rw-r--r-- | py/mock/backend.py | 1 | ||||
-rw-r--r-- | py/mock/plugins/root_cache.py | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/py/mock/backend.py b/py/mock/backend.py index 7d11532..6726deb 100644 --- a/py/mock/backend.py +++ b/py/mock/backend.py @@ -50,6 +50,7 @@ class Root(object): self._state_log = getLog("mock.Root.state") # config options + self.configs = config['config_paths'] self.chrootuid = config['chrootuid'] self.chrootuser = 'mockbuild' self.chrootgid = config['chrootgid'] diff --git a/py/mock/plugins/root_cache.py b/py/mock/plugins/root_cache.py index 9cb0a13..5382912 100644 --- a/py/mock/plugins/root_cache.py +++ b/py/mock/plugins/root_cache.py @@ -61,12 +61,21 @@ class RootCache(object): if self.rootCacheLock is None: self.rootCacheLock = open(os.path.join(self.rootSharedCachePath, "rootcache.lock"), "a+") - # check cache age: + # check cache status try: + # see if it aged out statinfo = os.stat(self.rootCacheFile) file_age_days = (time.time() - statinfo.st_ctime) / (60 * 60 * 24) if file_age_days > self.root_cache_opts['max_age_days']: + getLog().info("root cache aged out! cache will be rebuilt") os.unlink(self.rootCacheFile) + else: + # make sure no config file is newer than the cache file + for cfg in self.rootObj.configs: + if os.stat(cfg).st_mtime > statinfo.st_mtime: + getLog().info("%s newer than root cache; cache will be rebuilt" % cfg) + os.unlink(self.rootCacheFile) + break except OSError: pass |