Skip to content

Commit 2049f48

Browse files
JoMessinagplanchat
andauthored
Improve check dir exists
Co-authored-by: Grégory PLANCHAT <[email protected]>
1 parent 44761cb commit 2049f48

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Adapter/Filesystem/Satellite.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,11 @@ public function build(
4848
fclose($stream);
4949
}
5050
} else {
51-
$stream = fopen($this->workdir.'/'.$file->getPath(), 'wb');
52-
if (!$stream) {
53-
$dirname = dirname($this->workdir.'/'.$file->getPath());
54-
if (!is_dir($dirname))
55-
{
56-
mkdir($dirname, 0755, true);
57-
}
58-
$stream = fopen($this->workdir.'/'.$file->getPath(), 'wb');
51+
$dirname = dirname($this->workdir.'/'.$file->getPath());
52+
if (!file_exists($dirname)) {
53+
mkdir($dirname, 0755, true);
5954
}
55+
$stream = fopen($this->workdir.'/'.$file->getPath(), 'wb');
6056
stream_copy_to_stream($file->asResource(), $stream);
6157
fclose($stream);
6258
}

0 commit comments

Comments
 (0)