Merge pull request #96 from nextcloud/fix/95/don't-crash-during-removal

don't crash during container removal if the container doesn't exist
This commit is contained in:
Simon L 2022-01-13 16:46:02 +01:00 committed by GitHub
commit 54e7bcf1e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -125,7 +125,11 @@ class DockerActionManager
$url = $this->BuildApiUrl(sprintf('containers/%s', urlencode($container->GetIdentifier())));
try {
$this->guzzleClient->delete($url);
} catch (\Exception $e) {}
} catch (\GuzzleHttp\Exception\RequestException $e) {
if ($e->getCode() !== 404) {
throw $e;
}
}
}
public function GetLogs(Container $container) : string
@ -426,7 +430,7 @@ class DockerActionManager
],
]
);
} catch (ServerException $e) {}
} catch (\GuzzleHttp\Exception\RequestException $e) {}
}
private function ConnectContainerIdToNetwork(string $id)
@ -482,7 +486,13 @@ class DockerActionManager
public function StopContainer(Container $container) {
$url = $this->BuildApiUrl(sprintf('containers/%s/stop?t=%s', urlencode($container->GetIdentifier()), $container->GetMaxShutdownTime()));
$this->guzzleClient->post($url);
try {
$this->guzzleClient->post($url);
} catch (\GuzzleHttp\Exception\RequestException $e) {
if ($e->getCode() !== 404 && $e->getCode() !== 304) {
throw $e;
}
}
}
public function GetBackupcontainerExitCode() : int