Bug Report #2942

Kohana_Cache_Exception [ 0 ]: Kohana_Cache_File::_delete_file failed to delete directory

Added by 宗鑫 朱 about 4 years ago. Updated about 4 years ago.

Status:ClosedStart date:06/10/2010
Priority:NormalDue date:
Assignee:Sam de Freyssinet% Done:

100%

Category:Modules:Cache
Target version:v3.0.7
Resolution:fixed Points:

Description

Kohana_Cache_Exception [ 0 ]: Kohana_Cache_File::_delete_file failed to delete directory : D:\workspace\5pl\application\cache\.kohana_cache\76

MODPATH/cache\classes\kohana\cache\file.php [ 377 ]

372 catch (ErrorException $e)
373 {
374 // Catch any delete directory warnings
375 if ($e->getCode() === E_WARNING)
376 {
377 throw new Kohana_Cache_Exception(METHOD.' failed to delete directory : :directory', array(':directory' => $file->getRealPath()));
378 }
379 }
380 }
381 }
382 // Catch all exceptions

1.
MODPATH/cache\classes\kohana\cache\file.php [ 354 ] » Kohana_Cache_File->_delete_file(arguments)
file
object SplFileInfo(0) {
}
349                     if ($name != '.' and $name != '..')
350 {
351 // Create new file resource
352 $fp = new SplFileInfo($files->getRealPath());
353 // Delete the file
354 $this->_delete_file($fp);
355 }
356
357 // Move the file pointer on
358 $files->next();
359 }
2.
MODPATH/cache\classes\kohana\cache\file.php [ 299 ] » Kohana_Cache_File->_delete_file(arguments)
file
object RecursiveDirectoryIterator(0) {
}
retain_parent_directory
bool TRUE
294      
295 * @return boolean
296 */
297 public function delete_all()
298 {
299 return $this->_delete_file($this->_cache_dir, TRUE);
300 }
301
302 /
*
303 * Deletes files recursively and returns FALSE on any errors
304 *
3.
APPPATH/classes\controller\import.php [ 87 ] » Kohana_Cache_File->delete_all()
82         }
83 }
84
85 public function action_delete()
86 {
87 $this->file_instance->delete_all();//delete
88 }
89
90 } // End Welcome
4.
APPPATH/classes\controller\import.php [ 30 ] » Controller_Import->action_delete()
25         if ($validate->check())
26 {
27 $extension = strtolower(pathinfo($_FILES['file1']['name'], PATHINFO_EXTENSION));
28 Upload::save($_FILES['file1'], '2010.'.$extension, dirname(FILE));
29 $file = '2010.'.$extension;
30 $this->action_delete();
31 }
32 else
33 {
34 $errors = $validate->errors('upload');
35 if (!empty($errors)) print_r($errors);
5.
{PHP internal call} » Controller_Import->action_index()
6.
SYSPATH/classes\kohana\request.php [ 1025 ] » ReflectionMethod->invokeArgs(arguments)
object
object Controller_Import(2) {
private file_instance => object Cache_File(2) {
protected _cache_dir => object RecursiveDirectoryIterator(0) {
}
protected _config => array(3) (
"driver" => string(4) "file"
"cache_dir" => string(48) "D:\workspace\5pl\application\cache/.kohana_cache"
"default_expire" => integer 3600
)
}
public request => object Request(9) {
public route => object Route(4) {
protected _uri => string(32) "(<controller>(/<action>(/<id>)))"
protected _regex => array(0)
protected _defaults => array(2) (
"controller" => string(7) "welcome"
"action" => string(5) "index"
)
protected _route_regex => string(95) "#^(?:(?P<controller>[^/.,;?\n]++)(?:/(?P<action>[^/.,;?\n]++)(?:/(?P<id>[^/.,;?\n]++))?)?)?$#uD"
}
public status => integer 500
public response => string(0) ""
public headers => array(1) (
"Content-Type" => string(24) "text/html; charset=utf-8"
)
public directory => string(0) ""
public controller => string(6) "import"
public action => string(5) "index"
public uri => string(6) "import"
protected _params => array(0)
}
}
args
array(0)
1020 
1021 // Determine the action to use
1022 $action = empty($this->action) ? Route::$default_action : $this->action;
1023
1024 // Execute the main action with the parameters
1025 $class->getMethod('action_'.$action)->invokeArgs($controller, $this->_params);
1026
1027 // Execute the "after action" method
1028 $class->getMethod('after')->invoke($controller);
1029 }
1030 catch (Exception $e)
7.
APPPATH/bootstrap.php [ 97 ] » Kohana_Request->execute()
92 /**
93 * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
94 * If no source is specified, the URI will be automatically detected.
95 */
96 echo Request::instance()
97 ->execute()
98 ->send_headers()
99 ->response;
8.
DOCROOT/index.php [ 103 ] » require(arguments)

History

#1 Updated by 宗鑫 朱 about 4 years ago

modules/cache/classes/kohana/cache/file.php中第369行(line 369),增加unset($files);即可解决此问题:
try {
unset($files);
// Try to remove the parent directory
return rmdir($file->getRealPath());
}
为了规范和统一代码,建议将
if ($name != '.' and $name != '..')
改为
if (!$files->isDot())

#2 Updated by Sam de Freyssinet about 4 years ago

  • Category set to Modules:Cache
  • Status changed from New to Closed
  • Assignee set to Sam de Freyssinet
  • Target version changed from v3.0.6 to v3.0.7
  • % Done changed from 0 to 100
  • Resolution set to fixed

Also available in: Atom PDF