Fallback to downloading apps.json again if cache is messed up

This commit is contained in:
Alexandre Aubin 2020-04-23 17:51:56 +02:00
parent a85f6edbf0
commit de06a6bc49

View file

@ -556,13 +556,21 @@ class App():
if "id" in manifest: if "id" in manifest:
cachefile = "./.apps.json" cachefile = "./.apps.json"
app_list = None
if os.path.exists(cachefile) and time.time() - os.path.getmtime(cachefile) < 3600: if os.path.exists(cachefile) and time.time() - os.path.getmtime(cachefile) < 3600:
app_list = open(cachefile).read() try:
else: app_list = open(cachefile).read()
app_list = json.loads(app_list)
except:
print("Uuuuh failed to load apps.json from cache...")
app_list = None
if app_list is None:
app_list_url = "https://raw.githubusercontent.com/YunoHost/apps/master/apps.json" app_list_url = "https://raw.githubusercontent.com/YunoHost/apps/master/apps.json"
app_list = urlopen(app_list_url)['content'] app_list = urlopen(app_list_url)['content']
open(cachefile, "w").write(app_list) open(cachefile, "w").write(app_list)
app_list = json.loads(app_list) app_list = json.loads(app_list)
if manifest["id"] not in app_list: if manifest["id"] not in app_list:
print_warning("[YEP-1.2] This app is not registered in our applications list") print_warning("[YEP-1.2] This app is not registered in our applications list")