[pLog-svn] r2931 - plog/trunk/class/cache/Cache_Lite
mark at devel.lifetype.net
mark at devel.lifetype.net
Thu Feb 9 13:23:30 GMT 2006
Author: mark
Date: 2006-02-09 13:23:29 +0000 (Thu, 09 Feb 2006)
New Revision: 2931
Modified:
plog/trunk/class/cache/Cache_Lite/Lite.php
Log:
I just rewrite the _write()function in lite.php, it seems fixed the bug of the cache_list version 1.6 in linux.
I also submit a bug report to the cache_lite author, hope he can include the bug fix in coming verion 1.7
Modified: plog/trunk/class/cache/Cache_Lite/Lite.php
===================================================================
--- plog/trunk/class/cache/Cache_Lite/Lite.php 2006-02-07 14:27:14 UTC (rev 2930)
+++ plog/trunk/class/cache/Cache_Lite/Lite.php 2006-02-09 13:23:29 UTC (rev 2931)
@@ -577,7 +577,7 @@
}
}
break;
- case 'notingrou':
+ case 'notingroup':
if (!strpos($file2, $motif, 0)) {
$result = ($result and ($this->_unlink($file2)));
}
@@ -701,33 +701,27 @@
*/
function _write($data)
{
- $try = 1;
- while ($try<=2) {
- $fp = @fopen($this->_file, "wb");
- if ($fp) {
- if ($this->_fileLocking) @flock($fp, LOCK_EX);
- if ($this->_readControl) {
- @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
- }
- $len = strlen($data);
- @fwrite($fp, $data, $len);
- if ($this->_fileLocking) @flock($fp, LOCK_UN);
- @fclose($fp);
- return true;
- } else {
- if (($try==1) and ($this->_hashedDirectoryLevel>0)) {
- $hash = md5($this->_fileName);
- $root = $this->_cacheDir;
- for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
- $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
- @mkdir($root, $this->_hashedDirectoryUmask);
- }
- $try = 2;
- } else {
- $try = 999;
- }
- }
+ if(!is_dir(dirname($this->_file)) && ($this->_hashedDirectoryLevel>0)) {
+ $hash = md5($this->_fileName);
+ $root = $this->_cacheDir;
+ for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
+ $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
+ if(!is_dir($root)) @mkdir($root, $this->_hashedDirectoryUmask);
+ }
}
+
+ $fp = @fopen($this->_file, "wb");
+ if ($fp) {
+ if ($this->_fileLocking) @flock($fp, LOCK_EX);
+ if ($this->_readControl) {
+ @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
+ }
+ $len = strlen($data);
+ @fwrite($fp, $data, $len);
+ if ($this->_fileLocking) @flock($fp, LOCK_UN);
+ @fclose($fp);
+ return true;
+ }
$this->log->log('Unable to write cache file : '.$this->_file, LOGGER_PRIO_ERROR );
return false;
}
More information about the pLog-svn
mailing list