Skip to content

Commit 1ea7cd5

Browse files
author
arcfieldOSS
committed
reverting reader now that files.php always copies into-place
modifying files to check for double-mkdir() and only throw an exception if the subdir either doesn't exist or can't be written to
1 parent 1e06d47 commit 1ea7cd5

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

phpfastcache/3.0.0/abstract.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,24 @@ protected function required_extension($name) {
270270

271271

272272
protected function readfile($file) {
273+
if(function_exists("file_get_contents")) {
274+
return @file_get_contents($file);
275+
} else {
273276
$string = "";
274277

275278
$file_handle = @fopen($file, "r");
276279
if(!$file_handle) {
277280
throw new Exception("Can't Read File",96);
278281

279282
}
280-
if (flock($file_handle, LOCK_SH | LOCK_NB)) {
281-
while (!feof($file_handle)) {
282-
$line = fgets($file_handle);
283-
$string .= $line;
284-
}
285-
} else {
286-
throw new Exception("Can't Read File",96);
283+
while (!feof($file_handle)) {
284+
$line = fgets($file_handle);
285+
$string .= $line;
287286
}
288287
fclose($file_handle);
289288

290289
return $string;
290+
}
291291
}
292292

293293

phpfastcache/3.0.0/drivers/files.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ private function getFilePath($keyword, $skip = false) {
5252
* Skip Create Sub Folders;
5353
*/
5454
if($skip == false) {
55-
if(!@file_exists($path)) {
56-
if(!@mkdir($path,$this->__setChmodAuto())) {
55+
//if it doesn't exist, I can't create it, and nobody beat me to creating it:
56+
if(!@is_dir($path) && !@mkdir($path,$this->__setChmodAuto()) && !@is_dir($path)) {
5757
throw new Exception("PLEASE CHMOD ".$this->getPath()." - 0777 OR ANY WRITABLE PERMISSION!",92);
58-
}
59-
60-
} elseif(!is_writeable($path)) {
61-
if(!chmod($path,$this->__setChmodAuto())) {
58+
}
59+
//if it does exist (after someone beat me to it, perhaps), but isn't writable or fixable:
60+
if(@is_dir($path) && !is_writeable($path) && !@chmod($path,$this->__setChmodAuto())) {
6261
throw new Exception("PLEASE CHMOD ".$this->getPath()." - 0777 OR ANY WRITABLE PERMISSION!",92);
63-
}
6462
}
6563
}
6664

0 commit comments

Comments
 (0)