1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

Smarter error reporting when failing to refresh cache

This commit is contained in:
Alexandre Aubin 2020-05-06 16:10:45 +00:00
parent 7a33f8af9a
commit 85fd0ce3fa

View file

@ -63,12 +63,12 @@ def refresh_all_caches():
try:
init_cache(app, infos)
except Exception as e:
error("Could not init cache for %s: %s" % (app, e))
error("Failed to init cache for %s" % app)
else:
try:
refresh_cache(app, infos)
except Exception as e:
error("Could not refresh cache for %s: %s" % (app, e))
error("Failed to not refresh cache for %s" % app)
def init_cache(app, infos):
@ -90,9 +90,17 @@ def refresh_cache(app, infos):
if os.path.exists(fetch_head) and now - os.path.getmtime(fetch_head) < 3600:
return
try:
git("remote set-url origin " + infos["url"], in_folder=app_cache_folder(app))
git("fetch --quiet origin master --force", in_folder=app_cache_folder(app))
git("reset origin/master --hard", in_folder=app_cache_folder(app))
except:
# Sometimes there are tmp issue such that the refresh cache ..
# we don't trigger an error unless the cache hasnt been updated since more than 24 hours
if os.path.exists(fetch_head) and now - os.path.getmtime(fetch_head) < 24*3600:
pass
else:
raise
################################