From 82c150b72f88c3e1ec5080fba73de28b78931334 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 9 Mar 2016 11:54:30 -0600 Subject: [PATCH] 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 --- contrib/inventory/openstack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/inventory/openstack.py b/contrib/inventory/openstack.py index 1c7207a9e17..cc1f6dbed67 100755 --- a/contrib/inventory/openstack.py +++ b/contrib/inventory/openstack.py @@ -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: