Skip to content

Commit

Permalink
Merge pull request #4066 from nextcloud/enh/4056/fix-image-check
Browse files Browse the repository at this point in the history
only check if the image is actually there if no image is there
  • Loading branch information
szaimen authored Jan 17, 2024
2 parents 852798d + 61caa08 commit 2c951a7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,19 @@ public function PullImage(Container $container) : void
$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.");
}
}
}

Expand Down

0 comments on commit 2c951a7

Please sign in to comment.