Revert "Reduce fileclient.get_file latency by merging _file_find and _file_hash"

This reverts commit 94c62388e7.
This commit is contained in:
Daniel Wallace 2017-09-08 15:07:44 -06:00 committed by rallytime
parent 7fda186b18
commit ea6e661755

View File

@ -1270,10 +1270,10 @@ class RemoteClient(Client):
hash_type = self.opts.get('hash_type', 'md5')
ret['hsum'] = salt.utils.get_hash(path, form=hash_type)
ret['hash_type'] = hash_type
return ret, list(os.stat(path))
return ret
load = {'path': path,
'saltenv': saltenv,
'cmd': '_file_hash_and_stat'}
'cmd': '_file_hash'}
return self.channel.send(load)
def hash_file(self, path, saltenv='base'):
@ -1282,14 +1282,33 @@ class RemoteClient(Client):
master file server prepend the path with salt://<file on server>
otherwise, prepend the file with / for a local file.
'''
return self.__hash_and_stat_file(path, saltenv)[0]
return self.__hash_and_stat_file(path, saltenv)
def hash_and_stat_file(self, path, saltenv='base'):
'''
The same as hash_file, but also return the file's mode, or None if no
mode data is present.
'''
return self.__hash_and_stat_file(path, saltenv)
hash_result = self.hash_file(path, saltenv)
try:
path = self._check_proto(path)
except MinionError as err:
if not os.path.isfile(path):
return hash_result, None
else:
try:
return hash_result, list(os.stat(path))
except Exception:
return hash_result, None
load = {'path': path,
'saltenv': saltenv,
'cmd': '_file_find'}
fnd = self.channel.send(load)
try:
stat_result = fnd.get('stat')
except AttributeError:
stat_result = None
return hash_result, stat_result
def list_env(self, saltenv='base'):
'''