Skip to content

Commit ac789d3

Browse files
authored
Merge pull request #386 from Golodnyi/final
optimized code
2 parents b1bfaf6 + 404eebc commit ac789d3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/phpFastCache/Core/PathSeekerTrait.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,20 @@ public function getPath($readonly = false)
8282
if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
8383
if (!@file_exists($full_path)) {
8484
@mkdir($full_path, $this->setChmodAuto(), true);
85-
}else if (!@is_writable($full_path)) {
86-
@chmod($full_path, $this->setChmodAuto());
87-
}
88-
if (!@is_writable($full_path)) {
89-
/**
90-
* Switch back to tmp dir
91-
* again if the path is not writable
92-
*/
93-
$full_path = $full_path_tmp;
94-
if (!@file_exists($full_path)) {
95-
@mkdir($full_path, $this->setChmodAuto(), true);
85+
}elseif (!@is_writable($full_path)) {
86+
if (!@chmod($full_path, $this->setChmodAuto()))
87+
{
88+
/**
89+
* Switch back to tmp dir
90+
* again if the path is not writable
91+
*/
92+
$full_path = $full_path_tmp;
93+
if (!@file_exists($full_path)) {
94+
@mkdir($full_path, $this->setChmodAuto(), true);
95+
}
9696
}
9797
}
98+
9899
/**
99100
* In case there is no directory
100101
* writable including tye temporary

0 commit comments

Comments
 (0)