From 2049f482e293bc420000101cbbb921ebe2aef142 Mon Sep 17 00:00:00 2001 From: Jonathan <99172532+JoMessina@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:45:37 +0100 Subject: [PATCH] Improve check dir exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégory PLANCHAT --- src/Adapter/Filesystem/Satellite.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Adapter/Filesystem/Satellite.php b/src/Adapter/Filesystem/Satellite.php index 9e3bd2ac..b02f5fc5 100644 --- a/src/Adapter/Filesystem/Satellite.php +++ b/src/Adapter/Filesystem/Satellite.php @@ -48,15 +48,11 @@ public function build( fclose($stream); } } else { - $stream = fopen($this->workdir.'/'.$file->getPath(), 'wb'); - if (!$stream) { - $dirname = dirname($this->workdir.'/'.$file->getPath()); - if (!is_dir($dirname)) - { - mkdir($dirname, 0755, true); - } - $stream = fopen($this->workdir.'/'.$file->getPath(), 'wb'); + $dirname = dirname($this->workdir.'/'.$file->getPath()); + if (!file_exists($dirname)) { + mkdir($dirname, 0755, true); } + $stream = fopen($this->workdir.'/'.$file->getPath(), 'wb'); stream_copy_to_stream($file->asResource(), $stream); fclose($stream); }