Refactor directory creation

This commit is contained in:
Niklas Keller
2018-01-11 17:00:27 +01:00
parent 19f6550e33
commit 69bc88daf1
3 changed files with 18 additions and 6 deletions

View File

@@ -47,8 +47,12 @@ class CertificateStore {
$chain = \array_slice($certificates, 1);
$path = $this->root . '/' . $commonName;
if (!(yield File\isdir($path)) && !(yield File\mkdir($path, 0644, true)) && !(yield File\isdir($path))) {
throw new FilesystemException("Couldn't create certificate directory: '{$path}'");
if (!yield File\isdir($path)) {
yield File\mkdir($path, 0644, true);
if (!yield File\isdir($path)) {
throw new FilesystemException("Couldn't create certificate directory: '{$path}'");
}
}
yield File\put($path . '/cert.pem', $certificates[0]);