mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-45654 cron: fix non-empty directories deletion
Remove errors when attempting to delete non-empty directories when child directories do not get removed since the mtime was updated when files were removed from the child directory.
This commit is contained in:
parent
a929fd50f9
commit
75b70ab6cd
2 changed files with 83 additions and 56 deletions
|
@ -60,8 +60,11 @@ class file_temp_cleanup_task extends scheduled_task {
|
|||
// Check if file or directory is older than the given time.
|
||||
if ($iter->getMTime() < $time) {
|
||||
if ($iter->isDir() && !$iter->isDot()) {
|
||||
if (@rmdir($node) === false) {
|
||||
mtrace("Failed removing directory '$node'.");
|
||||
// Don't attempt to delete the directory if it isn't empty.
|
||||
if (!glob($node. DIRECTORY_SEPARATOR . '*')) {
|
||||
if (@rmdir($node) === false) {
|
||||
mtrace("Failed removing directory '$node'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($iter->isFile()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue