From 61caa08b10410de7946cadccb5941812d4a05a46 Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 15 Jan 2024 11:24:09 +0100 Subject: [PATCH] only check if the image is actually there if no image is there Signed-off-by: Simon L --- php/src/Docker/DockerActionManager.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index ad4c12b1..68877cd1 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -582,12 +582,19 @@ class DockerActionManager $imageName = $this->BuildImageName($container); $encodedImageName = urlencode($imageName); $url = $this->BuildApiUrl(sprintf('images/create?fromImage=%s', $encodedImageName)); + $imageIsThere = true; try { - $this->guzzleClient->post($url); $imageUrl = $this->BuildApiUrl(sprintf('images/%s/json', $encodedImageName)); $this->guzzleClient->get($imageUrl)->getBody()->getContents(); } catch (\Throwable $e) { - throw new \Exception("Could not pull image " . $imageName . ". Please run 'sudo docker exec -it nextcloud-aio-mastercontainer docker pull " . $imageName . "' in order to find out why it failed."); + $imageIsThere = false; + } + try { + $this->guzzleClient->post($url); + } catch (RequestException $e) { + if ($imageIsThere === false) { + throw new \Exception("Could not pull image " . $imageName . ". Please run 'sudo docker exec -it nextcloud-aio-mastercontainer docker pull " . $imageName . "' in order to find out why it failed."); + } } }