From a05404ecf1b2e0290992870135d0ab0a58a698f5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 28 Apr 2026 18:01:16 +0000 Subject: [PATCH] Add pull-images button for pulling updates while containers are running Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/f657a21d-d2ba-4dfe-a84e-fc7d4f094ec5 Co-authored-by: szaimen <42591237+szaimen@users.noreply.github.com> --- php/public/index.php | 1 + php/src/Controller/DockerController.php | 21 ++++++++++++++++++--- php/templates/containers.twig | 8 ++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/php/public/index.php b/php/public/index.php index eb2a7878..eaf02fa0 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -105,6 +105,7 @@ $app->post('/api/docker/restore', AIO\Controller\DockerController::class . ':Sta $app->post('/api/docker/stop', AIO\Controller\DockerController::class . ':StopContainer'); $app->post('/api/docker/backup-reset-location', AIO\Controller\DockerController::class . ':DeleteBorgBackupConfig'); $app->post('/api/docker/prune', AIO\Controller\DockerController::class . ':SystemPrune'); +$app->post('/api/docker/pull-images', AIO\Controller\DockerController::class . ':PullImages'); $app->get('/api/docker/logs', AIO\Controller\DockerController::class . ':GetLogs'); $app->post('/api/auth/login', AIO\Controller\LoginController::class . ':TryLogin'); $app->get('/api/auth/getlogin', AIO\Controller\LoginController::class . ':GetTryLogin'); diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index 66e8a3e2..b90fc221 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -45,15 +45,15 @@ readonly class DockerController { $this->dockerActionManager->ConnectContainerToNetwork($container); } - private function PerformRecursiveImagePull(string $id) : void { + private function PerformRecursiveImagePull(string $id, ?\Closure $addToStreamingResponseBody = null) : void { $container = $this->containerDefinitionFetcher->GetContainerById($id); // Pull all dependencies first and then itself foreach($container->dependsOn as $dependency) { - $this->PerformRecursiveImagePull($dependency); + $this->PerformRecursiveImagePull($dependency, $addToStreamingResponseBody); } - $this->dockerActionManager->PullImage($container, true); + $this->dockerActionManager->PullImage($container, true, $addToStreamingResponseBody); } public function PullAllContainerImages(): void { @@ -63,6 +63,21 @@ readonly class DockerController { $this->PerformRecursiveImagePull($id); } + public function PullImages(Request $request, Response $response, array $args) : Response { + // Get streaming response start and closure + $nonbufResp = $this->startStreamingResponse($response); + $addToStreamingResponseBody = $this->getAddToStreamingResponseBody($nonbufResp); + + $id = self::TOP_CONTAINER; + $this->PerformRecursiveImagePull($id, $addToStreamingResponseBody); + + $nonbufResp->getBody()->write('
⚠️ Container updates are available. Click on Stop containers and Start and update containers to update them. You should consider creating a backup first.
+ {% if isAnyRunning == true and isApacheStarting != true %} +Alternatively, you can already pull the new images now while your containers are still running. The new images will automatically be used whenever the containers are recreated manually or automatically via AIO.
+ + {% endif %} {% endif %} {% else %} {% if is_mastercontainer_update_available == false %}