|
|
07a10e |
commit 79591f49db4faec56a846ddf16a77004b8579ee7
|
|
|
07a10e |
Author: Michal Domonkos <mdomonko@redhat.com>
|
|
|
07a10e |
Date: Thu Dec 15 16:23:10 2016 +0100
|
|
|
07a10e |
|
|
|
07a10e |
Don't recommend makecache if just running. BZ 1369389
|
|
|
07a10e |
|
|
|
07a10e |
Also includes any other commands that would result in all repos obeying
|
|
|
07a10e |
metadata_expire such as "yum install" (depending on the actual value of
|
|
|
07a10e |
metadata_expire_filter).
|
|
|
07a10e |
|
|
|
07a10e |
diff --git a/cli.py b/cli.py
|
|
|
07a10e |
index 54a2e81..862992b 100755
|
|
|
07a10e |
--- a/cli.py
|
|
|
07a10e |
+++ b/cli.py
|
|
|
07a10e |
@@ -450,11 +450,21 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
|
|
|
07a10e |
|
|
|
07a10e |
if not ts_min:
|
|
|
07a10e |
cacheReq = 'write'
|
|
|
07a10e |
- elif warning and (time.time() - ts_max) > (60 * 60 * 24 * 14):
|
|
|
07a10e |
- self.logger.warning(_("Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast"))
|
|
|
07a10e |
|
|
|
07a10e |
+ all_obey = True
|
|
|
07a10e |
for repo in self.repos.sort():
|
|
|
07a10e |
repo._metadata_cache_req = cacheReq
|
|
|
07a10e |
+ if repo._matchExpireFilter():
|
|
|
07a10e |
+ all_obey = False
|
|
|
07a10e |
+
|
|
|
07a10e |
+ if warning and ts_min and (time.time() - ts_max) > (60 * 60 * 24 * 14):
|
|
|
07a10e |
+ # The warning makes no sense if we're already running a command
|
|
|
07a10e |
+ # that requires current repodata across all repos (such as "yum
|
|
|
07a10e |
+ # makecache" or others, depending on metadata_expire_filter), so
|
|
|
07a10e |
+ # don't give it if that's the case.
|
|
|
07a10e |
+ if all_obey:
|
|
|
07a10e |
+ return
|
|
|
07a10e |
+ self.logger.warning(_("Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast"))
|
|
|
07a10e |
|
|
|
07a10e |
def _shell_history_write(self):
|
|
|
07a10e |
if not hasattr(self, '_shell_history_cmds'):
|
|
|
07a10e |
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
|
|
|
07a10e |
index c6bed82..0c63de3 100644
|
|
|
07a10e |
--- a/yum/yumRepo.py
|
|
|
07a10e |
+++ b/yum/yumRepo.py
|
|
|
07a10e |
@@ -1145,33 +1145,39 @@ Insufficient space in download directory %s
|
|
|
07a10e |
self._metadataCurrent = False
|
|
|
07a10e |
return self._metadataCurrent
|
|
|
07a10e |
|
|
|
07a10e |
- def withinCacheAge(self, myfile, expiration_time, expire_req_filter=True):
|
|
|
07a10e |
- """check if any file is older than a certain amount of time. Used for
|
|
|
07a10e |
- the cachecookie and the mirrorlist
|
|
|
07a10e |
- return True if w/i the expiration time limit
|
|
|
07a10e |
- false if the time limit has expired
|
|
|
07a10e |
-
|
|
|
07a10e |
- Additionally compare the file to age of the newest .repo or yum.conf
|
|
|
07a10e |
- file. If any of them are newer then invalidate the cache
|
|
|
07a10e |
- """
|
|
|
07a10e |
-
|
|
|
07a10e |
+ def _matchExpireFilter(self):
|
|
|
07a10e |
+ """Return whether cache_req matches metadata_expire_filter."""
|
|
|
07a10e |
# Never/write means we just skip this...
|
|
|
07a10e |
- if (expire_req_filter and hasattr(self, '_metadata_cache_req') and
|
|
|
07a10e |
- self._metadata_cache_req.startswith("read-only:") and
|
|
|
07a10e |
- self.metadata_expire_filter.startswith("read-only:")):
|
|
|
07a10e |
+ if (hasattr(self, '_metadata_cache_req') and
|
|
|
07a10e |
+ self._metadata_cache_req.startswith("read-only:") and
|
|
|
07a10e |
+ self.metadata_expire_filter.startswith("read-only:")):
|
|
|
07a10e |
|
|
|
07a10e |
cache_filt = self.metadata_expire_filter[len("read-only:"):]
|
|
|
07a10e |
cache_req = self._metadata_cache_req[len("read-only:"):]
|
|
|
07a10e |
|
|
|
07a10e |
if cache_filt == 'future':
|
|
|
07a10e |
assert cache_req in ('past', 'present', 'future')
|
|
|
07a10e |
- expiration_time = -1
|
|
|
07a10e |
+ return True
|
|
|
07a10e |
if cache_filt == 'present':
|
|
|
07a10e |
if cache_req in ('past', 'present'):
|
|
|
07a10e |
- expiration_time = -1
|
|
|
07a10e |
+ return True
|
|
|
07a10e |
if cache_filt == 'past':
|
|
|
07a10e |
if cache_req == 'past':
|
|
|
07a10e |
- expiration_time = -1
|
|
|
07a10e |
+ return True
|
|
|
07a10e |
+ return False
|
|
|
07a10e |
+
|
|
|
07a10e |
+ def withinCacheAge(self, myfile, expiration_time, expire_req_filter=True):
|
|
|
07a10e |
+ """check if any file is older than a certain amount of time. Used for
|
|
|
07a10e |
+ the cachecookie and the mirrorlist
|
|
|
07a10e |
+ return True if w/i the expiration time limit
|
|
|
07a10e |
+ false if the time limit has expired
|
|
|
07a10e |
+
|
|
|
07a10e |
+ Additionally compare the file to age of the newest .repo or yum.conf
|
|
|
07a10e |
+ file. If any of them are newer then invalidate the cache
|
|
|
07a10e |
+ """
|
|
|
07a10e |
+
|
|
|
07a10e |
+ if expire_req_filter and self._matchExpireFilter():
|
|
|
07a10e |
+ expiration_time = -1
|
|
|
07a10e |
|
|
|
07a10e |
# -1 is special and should never get refreshed
|
|
|
07a10e |
if expiration_time == -1 and os.path.exists(myfile):
|