mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #50252 from dwoz/backport_fs_fix
[2017.7] backport - Do not allow age to be a negative number
This commit is contained in:
commit
e535b3846c
1 changed files with 14 additions and 1 deletions
|
@ -120,7 +120,20 @@ def check_file_list_cache(opts, form, list_cache, w_lock):
|
|||
if os.path.exists(list_cache):
|
||||
# calculate filelist age is possible
|
||||
cache_stat = os.stat(list_cache)
|
||||
age = time.time() - cache_stat.st_mtime
|
||||
# st_time can have a greater precision than time, removing
|
||||
# float precision makes sure age will never be a negative
|
||||
# number.
|
||||
current_time = int(time.time())
|
||||
file_mtime = int(cache_stat.st_mtime)
|
||||
if file_mtime > current_time:
|
||||
log.debug(
|
||||
'Cache file modified time is in the future, ignoring. '
|
||||
'file=%s mtime=%s current_time=%s',
|
||||
list_cache, current_time, file_mtime
|
||||
)
|
||||
age = 0
|
||||
else:
|
||||
age = current_time - file_mtime
|
||||
else:
|
||||
# if filelist does not exists yet, mark it as expired
|
||||
age = opts.get('fileserver_list_cache_time', 20) + 1
|
||||
|
|
Loading…
Add table
Reference in a new issue