Skip to content

Commit

Permalink
Fix cacheReq manipulation. BZ 1039028.
Browse files Browse the repository at this point in the history
 Only look at enabled repos. for cacheReq cookie comparisons. BZ 1039028.

 Move all the cacheReq repo. setting into a function.

 Use the function everywhere so we don't overwrite the manipulated value with
the generic value.
  • Loading branch information
james-antill committed Dec 6, 2013
1 parent ade4e34 commit 84876b2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,13 @@ def parseCommands(self):
self.basecmd, sys.argv[0])
raise CliError

self._set_repos_cache_req()

self.yum_cli_commands[self.basecmd].doCheck(self, self.basecmd, self.extcmds)

def _set_repos_cache_req(self, warning=True):
""" Set the cacheReq attribute from the commands to the repos. """

cmd = self.yum_cli_commands[self.basecmd]
cacheReq = 'write'
if hasattr(cmd, 'cacheRequirement'):
Expand All @@ -404,7 +411,7 @@ def parseCommands(self):
# they are _really_ old.
ts_min = None
ts_max = None
for repo in self.repos.sort():
for repo in self.repos.listEnabled():
if not os.path.exists(repo.metadata_cookie):
ts_min = None
break
Expand All @@ -428,14 +435,12 @@ def parseCommands(self):

if not ts_min:
cacheReq = 'write'
elif (time.time() - ts_max) > (60 * 60 * 24 * 14):
elif warning and (time.time() - ts_max) > (60 * 60 * 24 * 14):
self.logger.warning(_("Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast"))

for repo in self.repos.sort():
repo._metadata_cache_req = cacheReq

self.yum_cli_commands[self.basecmd].doCheck(self, self.basecmd, self.extcmds)

def _shell_history_write(self):
if not hasattr(self, '_shell_history_cmds'):
return
Expand Down Expand Up @@ -560,11 +565,7 @@ def doCommands(self):

# This should already have been done at doCheck() time, but just in
# case repos. got added or something do it again.
cacheReq = 'write'
if hasattr(cmd, 'cacheRequirement'):
cacheReq = cmd.cacheRequirement(self, self.basecmd, self.extcmds)
for repo in self.repos.sort():
repo._metadata_cache_req = cacheReq
self._set_repos_cache_req(warning=False)

return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)

Expand Down

0 comments on commit 84876b2

Please sign in to comment.