Skip to content

Commit a8da292

Browse files
committed
Merge pull request #89 from czenker/master
Improvements for FileProvider
2 parents d575cd8 + 4cf8e65 commit a8da292

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

docs/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ For specific instructions on how to configure each provider, please view their d
2424
aws-provider
2525
iron-mq-provider
2626
sync-provider
27+
file-provider
2728
custom-provider
2829

2930
Caching

docs/file-provider.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
File Provider
22
-------------
33

4-
The file provider uses the filesystem to dispatches and resolves queued messages.
4+
The file provider uses the filesystem to dispatch and resolve queued messages.
55

66
Configuration
77
^^^^^^^^^^^^^
88

99
To designate a queue as file, set the ``driver`` of its provider to ``file``. You will
10-
need to a read-able and write-able path to store the messages.
10+
need to configure a readable and writable path to store the messages.
1111

1212
.. code-block:: yaml
1313

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)