Skip to content

Commit 4cf8e65

Browse files
committed
make FileProvider more robust towards missing directories
PHP's mkdir() does not create parent dirs, but Filesystem() does
1 parent 0853fd0 commit 4cf8e65

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/Provider/FileProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ public function publish(array $message, array $options = [])
4343
$fileName = microtime(false);
4444
$fileName = str_replace(' ', '', $fileName);
4545
$path = substr(hash('md5', $fileName), 0, 3);
46-
if (!is_dir($this->queuePath.DIRECTORY_SEPARATOR.$path)) {
47-
mkdir($this->queuePath.DIRECTORY_SEPARATOR.$path);
48-
}
46+
4947
$fs = new Filesystem();
48+
if (!$fs->exists($this->queuePath.DIRECTORY_SEPARATOR.$path)) {
49+
$fs->mkdir($this->queuePath.DIRECTORY_SEPARATOR.$path);
50+
}
51+
5052
$fs->dumpFile(
5153
$this->queuePath.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$fileName.'.json',
5254
json_encode($message)

0 commit comments

Comments
 (0)