From 23fba9ac2060cdddf940de46da98773df2b73b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Helfensd=C3=B6rfer?= Date: Thu, 7 Jan 2021 12:43:49 +0100 Subject: [PATCH] Code style optimizations --- src/AutoUpdate.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/AutoUpdate.php b/src/AutoUpdate.php index 5d9027a..fae88b7 100755 --- a/src/AutoUpdate.php +++ b/src/AutoUpdate.php @@ -1,15 +1,16 @@ -log->debug(sprintf('Creating new temporary directory "%s"', $dir)); - if (!mkdir($dir, 0755, true)) { + if (!mkdir($dir, 0755, true) && !is_dir($dir)) { $this->log->critical(sprintf('Could not create temporary directory "%s"', $dir)); return false; @@ -250,7 +251,7 @@ public function setInstallDir(string $dir): bool if (!is_dir($dir)) { $this->log->debug(sprintf('Creating new install directory "%s"', $dir)); - if (!mkdir($dir, 0755, true)) { + if (!mkdir($dir, 0755, true) && !is_dir($dir)) { $this->log->critical(sprintf('Could not create install directory "%s"', $dir)); return false; @@ -697,7 +698,9 @@ protected function simulateInstall(string $updateFile): bool // Check if parent directory is writable if (!is_dir($foldername)) { - mkdir($foldername); + if (!mkdir($foldername) && !is_dir($foldername)) { + throw new RuntimeException( sprintf( 'Directory "%s" was not created', $foldername ) ); + } $this->log->debug(sprintf('[SIMULATE] Create directory "%s"', $foldername)); $files[$i]['parent_folder_exists'] = false; @@ -812,7 +815,7 @@ protected function install(string $updateFile, bool $simulateInstall, string $ve $this->log->debug(sprintf('Updating file "%s"', $filename)); if (!is_dir($foldername)) { - if (!mkdir($foldername, $this->dirPermissions, true)) { + if (!mkdir($foldername, $this->dirPermissions, true) && !is_dir($foldername)) { $this->log->error(sprintf('Directory "%s" has to be writeable!', $foldername)); return false;