I have a website that has an assets directory. Sometimes I need to delete a whole folder and previously on AWS I had an EC2 with an EBS for storage, and it worked fine.
I'm now testing EFS to share the assets across multiple instances. The files are removed however when it goes to remove the directory it throws a warning saying the directory isn't empty:
ERROR [Warning]: rmdir(/path/): Directory not empty
Upon looking at the file system the directory is empty so I can only assume there is some lag. I've put a sleep function in to see if that fixes it as a test but it doesn't.
Permissions on the directory look correct and it has no issue saving / deleting files.
Is my only option to exec the rm -rf
command? The code that does the deleting below:
public function delTree($dir) {
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? $this->delTree($dir . $file . "/") : unlink("$dir/$file");
}
return rmdir($dir);
}