|
|
@ -979,14 +979,15 @@ def main():
|
|
|
|
tdelta = datetime.timedelta(seconds=p['cache_valid_time'])
|
|
|
|
tdelta = datetime.timedelta(seconds=p['cache_valid_time'])
|
|
|
|
if not mtimestamp + tdelta >= now:
|
|
|
|
if not mtimestamp + tdelta >= now:
|
|
|
|
# Retry to update the cache up to 3 times
|
|
|
|
# Retry to update the cache up to 3 times
|
|
|
|
|
|
|
|
err = ''
|
|
|
|
for retry in range(3):
|
|
|
|
for retry in range(3):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cache.update()
|
|
|
|
cache.update()
|
|
|
|
break
|
|
|
|
break
|
|
|
|
except apt.cache.FetchFailedException:
|
|
|
|
except apt.cache.FetchFailedException as e:
|
|
|
|
pass
|
|
|
|
err = to_native(e)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
module.fail_json(msg='Failed to update apt cache.')
|
|
|
|
module.fail_json(msg='Failed to update apt cache: %s' % err)
|
|
|
|
cache.open(progress=None)
|
|
|
|
cache.open(progress=None)
|
|
|
|
updated_cache = True
|
|
|
|
updated_cache = True
|
|
|
|
mtimestamp, updated_cache_time = get_updated_cache_time()
|
|
|
|
mtimestamp, updated_cache_time = get_updated_cache_time()
|
|
|
|