mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Detect empty cache files in openstack inventory
There are cases where it makes more sense to zero out a cache file as a form of invalidation instead of removing it. Detect those approrpriately
This commit is contained in:
parent
a52a561217
commit
82c150b72f
1 changed files with 1 additions and 1 deletions
|
@ -159,7 +159,7 @@ def is_cache_stale(cache_file, cache_expiration_time, refresh=False):
|
|||
''' Determines if cache file has expired, or if it is still valid '''
|
||||
if refresh:
|
||||
return True
|
||||
if os.path.isfile(cache_file):
|
||||
if os.path.isfile(cache_file) and os.path.getsize(cache_file) > 0:
|
||||
mod_time = os.path.getmtime(cache_file)
|
||||
current_time = time.time()
|
||||
if (mod_time + cache_expiration_time) > current_time:
|
||||
|
|
Loading…
Reference in a new issue