Skip to content

Commit

Permalink
wrap directory creation in try / catch.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 2, 2013
1 parent 2e6e27f commit 4841dc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Illuminate/Cache/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ public function put($key, $value, $minutes)
*/
protected function createCacheDirectory($path)
{
if ( ! $this->files->isDirectory($directory = dirname($path)))
try
{
$this->files->makeDirectory(dirname($path), 0777, true);
}
catch (\Exception $e)
{
$this->files->makeDirectory($directory, 0777, true);
//
}
}

Expand Down
1 change: 0 additions & 1 deletion tests/Cache/CacheFileStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function testPutCreatesMissingDirectories()
$files = $this->mockFilesystem();
$md5 = md5('foo');
$full_dir = __DIR__.'/'.substr($md5, 0, 2).'/'.substr($md5, 2, 2);
$files->expects($this->once())->method('isDirectory')->with($this->equalTo($full_dir))->will($this->returnValue(false));
$files->expects($this->once())->method('makeDirectory')->with($this->equalTo($full_dir), $this->equalTo(0777), $this->equalTo(true));
$files->expects($this->once())->method('put')->with($this->equalTo($full_dir.'/'.$md5));
$store = new FileStore($files, __DIR__);
Expand Down

2 comments on commit 4841dc8

@robclancy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this done? I am getting an error when using this package because mkdir(...) is throwing a warning and not an exception. Note I am using it outside of laravel. I can just revert but should I be making an issue?

@janhartigan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robclancy, I made an issue about this here if you're interested: #2518

Please sign in to comment.