Skip to content

Commit 6bfaa5d

Browse files
authored
Merge pull request #432 from landy2005/V6
Clean/delete parent cache directory if it empty after call deleteItem()/deleteItems() for Files driver.
2 parents 7af2880 + 728674a commit 6bfaa5d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/phpFastCache/Drivers/Files/Driver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ protected function driverDelete(CacheItemInterface $item)
118118
if ($item instanceof Item) {
119119
$file_path = $this->getFilePath($item->getKey(), true);
120120
if (file_exists($file_path) && @unlink($file_path)) {
121+
$dir = dirname($file_path);
122+
if (!(new \FilesystemIterator($dir))->valid()) {
123+
rmdir($dir);
124+
}
121125
return true;
122126
} else {
123127
return false;
@@ -193,4 +197,4 @@ public static function getRequiredOptions()
193197
{
194198
return ['path'];
195199
}
196-
}
200+
}

0 commit comments

Comments
 (0)