mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Revert "Reduce fileclient.get_file latency by merging _file_find and _file_hash"
This reverts commit 94c62388e7
.
This commit is contained in:
parent
7fda186b18
commit
ea6e661755
@ -1270,10 +1270,10 @@ class RemoteClient(Client):
|
|||||||
hash_type = self.opts.get('hash_type', 'md5')
|
hash_type = self.opts.get('hash_type', 'md5')
|
||||||
ret['hsum'] = salt.utils.get_hash(path, form=hash_type)
|
ret['hsum'] = salt.utils.get_hash(path, form=hash_type)
|
||||||
ret['hash_type'] = hash_type
|
ret['hash_type'] = hash_type
|
||||||
return ret, list(os.stat(path))
|
return ret
|
||||||
load = {'path': path,
|
load = {'path': path,
|
||||||
'saltenv': saltenv,
|
'saltenv': saltenv,
|
||||||
'cmd': '_file_hash_and_stat'}
|
'cmd': '_file_hash'}
|
||||||
return self.channel.send(load)
|
return self.channel.send(load)
|
||||||
|
|
||||||
def hash_file(self, path, saltenv='base'):
|
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>
|
master file server prepend the path with salt://<file on server>
|
||||||
otherwise, prepend the file with / for a local file.
|
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'):
|
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
|
The same as hash_file, but also return the file's mode, or None if no
|
||||||
mode data is present.
|
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'):
|
def list_env(self, saltenv='base'):
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user