fix(profiler): clear command does not work

- The loop is supposed to delete the files first and then the directories.
- getPathInfo returns a SplFileInfo object for the parent (the folder in our case).
- A non-empty directory cannot be deleted.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
Daniel Kesselberg 2024-09-20 18:14:33 +02:00
parent bc5222726b
commit 4ae10aa7f9
No known key found for this signature in database
GPG key ID: 4A81C29F63464E8F

View file

@ -81,11 +81,11 @@ class FileProfilerStorage {
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $file) {
$file = (string)$file->getPathInfo();
if (is_file($file)) {
unlink($file);
$path = $file->getPathname();
if (is_file($path)) {
unlink($path);
} else {
rmdir($file);
rmdir($path);
}
}
}