WCF icon indicating copy to clipboard operation
WCF copied to clipboard

Installer fails when recursively deleting a folder on BSD

Open Vringe opened this issue 1 year ago • 0 comments

We have some customers complaining about failing installations of Woltlab Suite. (Also tested on Core)

It looks like a problem related to BSD and NFS environments. It's a fundamental issue, which was discussed here a long time ago: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=57696#c14 https://forums.freebsd.org/threads/problem-wiith-removing-folders-on-nfs.82034/#post-531210

This is also kind of mentioned in the POSIX spec:

If a file is removed from or added to the directory after the most recent call to opendir() or rewinddir(), whether a subsequent call to readdir() returns an entry for that file is unspecified.

It fails when the installer tries to delete tmp files: https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/WCFSetup.class.php#L1072

I was able to implement a workaround by filling the iterator items into an array:

                 ),
                 \RecursiveIteratorIterator::CHILD_FIRST
             );
+             $tmpDirectoryIterator = iterator_to_array($tmpDirectoryIterator);
             foreach ($tmpDirectoryIterator as $tmpFile) {
                 if ($tmpFile->isDir()) {
                     \rmdir($tmpFile);

This may lead to out-of-memory situations depending on how many files there are. An other approach would be to get 20 files, delete them, and then get another 20 until the folder is empty.

Vringe avatar Feb 22 '24 08:02 Vringe