public MTimeProtectedFastFileStorage::garbageCollection()
Performs garbage collection on the storage.
The storage may choose to delete expired or invalidated items.
Overrides FileStorage::garbageCollection
File
- core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php, line 150
Class
- MTimeProtectedFastFileStorage
- Stores PHP code in files with securely hashed names.
Namespace
Drupal\Component\PhpStorage
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | public function garbageCollection() { $flags = \FilesystemIterator::CURRENT_AS_FILEINFO; $flags += \FilesystemIterator::SKIP_DOTS; foreach ( $this ->listAll() as $name ) { $directory = $this ->getContainingDirectoryFullPath( $name ); try { $dir_iterator = new \FilesystemIterator( $directory , $flags ); } catch (\UnexpectedValueException $e ) { // FilesystemIterator throws an UnexpectedValueException if the // specified path is not a directory, or if it is not accessible. continue ; } $directory_unlink = TRUE; $directory_mtime = filemtime ( $directory ); foreach ( $dir_iterator as $fileinfo ) { if ( $directory_mtime > $fileinfo ->getMTime()) { // Ensure the folder is writable. @ chmod ( $directory , 0777); @unlink( $fileinfo ->getPathName()); } else { // The directory still contains valid files. $directory_unlink = FALSE; } } if ( $directory_unlink ) { $this ->unlink( $name ); } } } |
Please login to continue.