From 47529bb46aa3c45623e31189ee9d78cb05d9c6ba Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Sat, 3 Oct 2020 08:26:55 -0700 Subject: [PATCH] fixed update functionality for if image is missing --- backend/api/actions/apps.py | 5 +++-- backend/api/utils.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/api/actions/apps.py b/backend/api/actions/apps.py index dc442a51..c3f51311 100644 --- a/backend/api/actions/apps.py +++ b/backend/api/actions/apps.py @@ -28,8 +28,9 @@ def check_app_updates(): dclient = docker.from_env() apps = dclient.containers.list(all=True) for app in apps: - if check_updates(app.image.tags[0]): - apps_list.append(app.name) + if app.attrs['Config']['Image']: + if check_updates(app.attrs['Config']['Image']): + apps_list.append(app.name) return apps_list def get_apps(): diff --git a/backend/api/utils.py b/backend/api/utils.py index 81574bfb..d48c2c89 100644 --- a/backend/api/utils.py +++ b/backend/api/utils.py @@ -11,6 +11,7 @@ from .settings import Settings import aiodocker import docker +from docker.errors import APIError import json settings = Settings() @@ -361,7 +362,10 @@ def check_updates(tag): if tag: dclient = docker.from_env() current = dclient.images.get(tag) - new = dclient.images.get_registry_data(tag) + try: + new = dclient.images.get_registry_data(tag) + except APIError as err: + return False if new.attrs['Descriptor']['digest'] in current.attrs['RepoDigests'][0]: return False else: