Skip to content

Commit

Permalink
Avoid deleting tag files for records added to the cache during clean. (
Browse files Browse the repository at this point in the history
  • Loading branch information
bob2021 committed Sep 19, 2023
1 parent a4b5062 commit 90ad5e7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions File.php
Expand Up @@ -434,7 +434,7 @@ protected function _path($id, $parts = false)
$partsArray = array();
$root = $this->_options['cache_dir'];
$prefix = $this->_options['file_name_prefix'];
if ($this->_options['hashed_directory_level']>0) {
if ($this->_options['hashed_directory_level'] > 0) {
$root .= $prefix . '--' . substr(md5($id), -$this->_options['hashed_directory_level']) . DIRECTORY_SEPARATOR;
$partsArray[] = $root;
}
Expand Down Expand Up @@ -469,6 +469,14 @@ protected function _clean($dir, $mode = Zend_Cache::CLEANING_MODE_ALL, $tags = a
if (!is_dir($dir)) {
return false;
}
if ($mode == 'all' && $dir === $this->_options['cache_dir']) {
$glob = glob($this->_tagFile('*'));
if ($glob !== false) {
foreach ($glob as $tagFile) {
@unlink($tagFile);
}
}
}
$result = true;
$glob = @glob($dir . $this->_options['file_name_prefix'] . '--*');
if ($glob === false) {
Expand Down Expand Up @@ -511,11 +519,6 @@ protected function _clean($dir, $mode = Zend_Cache::CLEANING_MODE_ALL, $tags = a
}
}
}
if ($mode == 'all') {
foreach (glob($this->_tagFile('*')) as $tagFile) {
@unlink($tagFile);
}
}
return $result;
}

Expand Down Expand Up @@ -737,7 +740,7 @@ protected function _filePutContents($file, $string)
*/
protected function _recursiveMkdirAndChmod($id)
{
if ($this->_options['hashed_directory_level'] <=0) {
if ($this->_options['hashed_directory_level'] <= 0) {
return true;
}
$partsArray = $this->_path($id, true);
Expand Down

0 comments on commit 90ad5e7

Please sign in to comment.