Merge pull request #22679 from jfindlay/merge_22219

merge #22219
This commit is contained in:
Thomas S Hatch 2015-04-22 10:47:45 -06:00
commit 2520e816bc
3 changed files with 46 additions and 5 deletions

View File

@ -939,6 +939,18 @@ class RemoteClient(Client):
dest is omitted, then the downloaded file will be placed in the minion
cache
'''
# Check if file exists on server, before creating files and
# directories
hash_server = self.hash_file(path, saltenv)
if hash_server == '':
log.debug(
'Could not find file from saltenv {0!r}, {1!r}'.format(
saltenv, path
)
)
return False
if env is not None:
salt.utils.warn_until(
'Boron',
@ -959,7 +971,6 @@ class RemoteClient(Client):
if dest2check and os.path.isfile(dest2check):
hash_local = self.hash_file(dest2check, saltenv)
hash_server = self.hash_file(path, saltenv)
if hash_local == hash_server:
log.info(
'Fetching file from saltenv {0!r}, ** skipped ** '

View File

@ -333,9 +333,8 @@ def cache_file(path, saltenv='base', env=None):
if '?env=' in path:
salt.utils.warn_until(
'Boron',
'Passing a salt environment should be done using '
'\'saltenv\' not \'env\'. This functionality will be '
'removed in Salt Boron.'
'Passing a salt environment should be done using \'saltenv\' '
'not \'env\'. This functionality will be removed in Salt Boron.'
)
env_splitter = '?env='
try:

View File

@ -126,8 +126,39 @@ def _get_pip_bin(bin_env):
return bin_env
def _process_salt_url(path, saltenv):
'''
Process 'salt://' and '?saltenv=' out of `path` and return the stripped
path and the saltenv.
'''
path = path.split('salt://', 1)[-1]
env_splitter = '?saltenv='
if '?env=' in path:
salt.utils.warn_until(
'Boron',
'Passing a salt environment should be done using \'saltenv\' '
'not \'env\'. This functionality will be removed in Salt Boron.'
)
env_splitter = '?env='
try:
path, saltenv = path.split(env_splitter)
except ValueError:
pass
return path, saltenv
def _get_cached_requirements(requirements, saltenv):
'''Get the location of a cached requirements file; caching if necessary.'''
'''
Get the location of a cached requirements file; caching if necessary.
'''
requirements_file, saltenv = _process_salt_url(requirements, saltenv)
if requirements_file not in __salt__['cp.list_master'](saltenv):
# Requirements file does not exist in the given saltenv.
return False
cached_requirements = __salt__['cp.is_cached'](
requirements, saltenv
)