mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-29 15:00:09 +00:00
@@ -286,8 +286,12 @@ readonly class DockerController {
|
||||
}
|
||||
|
||||
public function SystemPrune(Request $request, Response $response, array $args) : Response {
|
||||
$this->dockerActionManager->SystemPrune();
|
||||
return $response->withStatus(201)->withHeader('Location', '.');
|
||||
$results = $this->dockerActionManager->SystemPrune();
|
||||
$body = $response->getBody();
|
||||
$body->write(json_encode($results));
|
||||
return $response
|
||||
->withStatus(200)
|
||||
->withHeader('Content-Type', 'application/json; charset=utf-8');
|
||||
}
|
||||
|
||||
public function stopTopContainer() : void {
|
||||
|
||||
@@ -984,7 +984,7 @@ readonly class DockerActionManager {
|
||||
}
|
||||
}
|
||||
|
||||
public function SystemPrune(): void {
|
||||
public function SystemPrune(): array {
|
||||
$endpoints = [
|
||||
// Remove stopped containers
|
||||
'containers/prune',
|
||||
@@ -998,6 +998,7 @@ readonly class DockerActionManager {
|
||||
'build/prune',
|
||||
];
|
||||
|
||||
$results = [];
|
||||
foreach ($endpoints as $endpoint) {
|
||||
// Special-case images prune to include the dangling filter as requested
|
||||
if ($endpoint === 'images/prune') {
|
||||
@@ -1008,11 +1009,21 @@ readonly class DockerActionManager {
|
||||
}
|
||||
|
||||
try {
|
||||
$this->guzzleClient->post($url);
|
||||
$resp = $this->guzzleClient->post($url);
|
||||
$body = (string)$resp->getBody();
|
||||
$json = null;
|
||||
try {
|
||||
$json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (\Throwable $e) {
|
||||
// Non-JSON body, keep raw
|
||||
$json = $body;
|
||||
}
|
||||
$results[$endpoint] = $json;
|
||||
} catch (RequestException $e) {
|
||||
error_log(sprintf('Docker prune (%s) failed: %s', $endpoint, $e->getMessage()));
|
||||
$results[$endpoint] = ['error' => $e->getMessage()];
|
||||
// continue with next prune step
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user