From 44761cb4df32f987b02adc328a12939a8d8fd093 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 17 Jan 2024 11:38:44 +0100 Subject: [PATCH 1/3] manage creation of directory recursively when the file to copy is under a non-existent directory --- src/Adapter/Filesystem/Satellite.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Adapter/Filesystem/Satellite.php b/src/Adapter/Filesystem/Satellite.php index d8edbc01..9e3bd2ac 100644 --- a/src/Adapter/Filesystem/Satellite.php +++ b/src/Adapter/Filesystem/Satellite.php @@ -49,6 +49,14 @@ public function build( } } 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'); + } stream_copy_to_stream($file->asResource(), $stream); fclose($stream); } 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 2/3] 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); } From f8ee82baa5c08539cb85554d863fa1d66a5453bb Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 1 Feb 2024 11:07:49 +0100 Subject: [PATCH 3/3] cs-fixer changes --- .github/workflows/quality.yaml | 2 +- src/Adapter/Filesystem/Satellite.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index 81e014bd..75470482 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -14,7 +14,7 @@ jobs: run: | wget -q https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer chmod a+x php-cs-fixer - PHP_CS_FIXER_IGNORE_ENV=true ./php-cs-fixer fix src --dry-run + ./php-cs-fixer fix src --dry-run phpstan: runs-on: ubuntu-latest diff --git a/src/Adapter/Filesystem/Satellite.php b/src/Adapter/Filesystem/Satellite.php index b02f5fc5..05195d10 100644 --- a/src/Adapter/Filesystem/Satellite.php +++ b/src/Adapter/Filesystem/Satellite.php @@ -48,9 +48,9 @@ public function build( fclose($stream); } } else { - $dirname = dirname($this->workdir.'/'.$file->getPath()); + $dirname = \dirname($this->workdir.'/'.$file->getPath()); if (!file_exists($dirname)) { - mkdir($dirname, 0755, true); + mkdir($dirname, 0o755, true); } $stream = fopen($this->workdir.'/'.$file->getPath(), 'wb'); stream_copy_to_stream($file->asResource(), $stream);