Skip to content

Commit b6fd479

Browse files
authored
Merge pull request #431 from landy2005/final
Clean/delete parent cache dirrectory if it empty after call deleteItem()/deleteItems() for Files driver.
2 parents f9c0966 + b1de261 commit b6fd479

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
@@ -138,6 +138,10 @@ protected function driverDelete(CacheItemInterface $item)
138138
if ($item instanceof Item) {
139139
$file_path = $this->getFilePath($item->getKey(), true);
140140
if (file_exists($file_path) && @unlink($file_path)) {
141+
$dir = dirname($file_path);
142+
if (!(new \FilesystemIterator($dir))->valid()) {
143+
rmdir($dir);
144+
}
141145
return true;
142146
} else {
143147
return false;
@@ -236,4 +240,4 @@ public function getStats()
236240

237241
return $stat;
238242
}
239-
}
243+
}

0 commit comments

Comments
 (0)