mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
If windows pkg db hasn't been created yet, refresh the db instead of stacktracing (#36008)
* Don't raise an exception. Just return empty dict If the repo cache file doesn't exist, lets' just return an empty dict rather than raising an exception. * If repo cache file doesn't exist, refresh * add logging message * remove unused imports
This commit is contained in:
parent
6242702288
commit
116d7ac3e5
1 changed files with 4 additions and 8 deletions
|
@ -16,7 +16,6 @@ A module to manage software on Windows
|
|||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import errno
|
||||
import os
|
||||
import locale
|
||||
import logging
|
||||
|
@ -40,7 +39,7 @@ except ImportError:
|
|||
import shlex
|
||||
|
||||
# Import salt libs
|
||||
from salt.exceptions import CommandExecutionError, SaltRenderError
|
||||
from salt.exceptions import SaltRenderError
|
||||
import salt.utils
|
||||
import salt.syspaths
|
||||
from salt.exceptions import MinionError
|
||||
|
@ -1070,6 +1069,9 @@ def get_repo_data(saltenv='base'):
|
|||
# return __context__['winrepo.data']
|
||||
repocache_dir = _get_local_repo_dir(saltenv=saltenv)
|
||||
winrepo = 'winrepo.p'
|
||||
if not os.path.exists(os.path.join(repocache_dir, winrepo)):
|
||||
log.debug('No winrepo.p cache file. Refresh pkg db now.')
|
||||
refresh_db(saltenv=saltenv)
|
||||
try:
|
||||
with salt.utils.fopen(
|
||||
os.path.join(repocache_dir, winrepo), 'rb') as repofile:
|
||||
|
@ -1080,12 +1082,6 @@ def get_repo_data(saltenv='base'):
|
|||
log.exception(exc)
|
||||
return {}
|
||||
except IOError as exc:
|
||||
if exc.errno == errno.ENOENT:
|
||||
# File doesn't exist
|
||||
raise CommandExecutionError(
|
||||
'Windows repo cache doesn\'t exist, pkg.refresh_db likely '
|
||||
'needed'
|
||||
)
|
||||
log.error('Not able to read repo file')
|
||||
log.exception(exc)
|
||||
return {}
|
||||
|
|
Loading…
Add table
Reference in a new issue