Skip to content

Commit eca7290

Browse files
committed
optimized code
1 parent b1bfaf6 commit eca7290

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

src/phpFastCache/Core/PathSeekerTrait.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,23 @@ 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+
if (!@mkdir($full_path, $this->setChmodAuto(), true))
95+
{
96+
throw new phpFastCacheDriverException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
97+
}
98+
}
9699
}
97100
}
98-
/**
99-
* In case there is no directory
100-
* writable including tye temporary
101-
* one, we must throw an exception
102-
*/
103-
if (!@file_exists($full_path) || !@is_writable($full_path)) {
104-
throw new phpFastCacheDriverException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
105-
}
101+
106102
$this->tmp[ $full_path_hash ] = $full_path;
107103
$this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
108104
}

0 commit comments

Comments
 (0)