Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix a bug in the recursive rmdir
A directory containing a directory containing files where never deleted.

Example:

Let's consider this configuration:

```
/tmp/root
└── intermediate
	├── file1
	├── file2
    └── file3
```

This configuration was able to occured during a plugin update.

If NC was running a `rmdirr("/tmp/root");` (which seems to be done during a cron, but, that's not important), it would never deleted anything.

Indeed, the `$files` variable would contians only the `intermediate` directory.

Thus, during the loop to delete the content of the `/tmp/root` content, when `$fileInfo` will contains the descriptor of `/tmp/root/intermediate`, the `rmdir` PHP function would fails because this directory is not empty.... And maked the final `rmdir` (in the `$deleteSelf` condition).

Tested on `PHP 8.1.20 (built: Jun 15 2023 01:23:25) (NTS)`, the PHP version of the docker container provided by NC-AIO.

Signed-off-by: Ajabep <[email protected]>
  • Loading branch information
ajabep committed Jun 29, 2023
commit f1cd7e1d9dfacae6361a51d9e8e64744491874ee
2 changes: 1 addition & 1 deletion lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static function rmdirr($dir, $deleteSelf = true) {
if ($fileInfo->isLink()) {
unlink($fileInfo->getPathname());
} elseif ($fileInfo->isDir()) {
rmdir($fileInfo->getRealPath());
self::rmdirr($fileInfo->getRealPath());
} else {
unlink($fileInfo->getRealPath());
}
Expand Down