diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-05-02 18:45:09 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-05-02 18:45:09 +0200 |
commit | 9e18be642239a77014ff16598a50cd413b70af46 (patch) | |
tree | c7c747355ff1db1a81bacc97a9d3af0547edeae1 /lib/private | |
parent | 49d9631eee1616b9ae2846886c3d428236c5b81a (diff) | |
parent | 49822dfcdb752428b43040a26d97c5e52ecf3458 (diff) | |
download | nextcloud-server-9e18be642239a77014ff16598a50cd413b70af46.tar.gz nextcloud-server-9e18be642239a77014ff16598a50cd413b70af46.zip |
Merge pull request #8377 from youngguns-nl/issue_8376
RecursiveDirectoryIterator does not work on NFS
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/storage/local.php | 11 | ||||
-rw-r--r-- | lib/private/files/storage/mappedlocal.php | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index ff2949d33b6..de940fc7cdb 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -44,17 +44,26 @@ if (\OC_Util::runningOnWindows()) { new \RecursiveDirectoryIterator($this->datadir . $path), \RecursiveIteratorIterator::CHILD_FIRST ); - foreach ($it as $file) { + /** + * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach + * This bug is fixed in PHP 5.5.9 or before + * See #8376 + */ + $it->rewind(); + while ($it->valid()) { /** * @var \SplFileInfo $file */ + $file = $it->current(); if (in_array($file->getBasename(), array('.', '..'))) { + $it->next(); continue; } elseif ($file->isDir()) { rmdir($file->getPathname()); } elseif ($file->isFile() || $file->isLink()) { unlink($file->getPathname()); } + $it->next(); } return rmdir($this->datadir . $path); } catch (\UnexpectedValueException $e) { diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index 75582fd6c83..07691661644 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -39,17 +39,26 @@ class MappedLocal extends \OC\Files\Storage\Common{ new \RecursiveDirectoryIterator($this->buildPath($path)), \RecursiveIteratorIterator::CHILD_FIRST ); - foreach ($it as $file) { + /** + * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach + * This bug is fixed in PHP 5.5.9 or before + * See #8376 + */ + $it->rewind(); + while ($it->valid()) { /** * @var \SplFileInfo $file */ + $file = $it->current(); if (in_array($file->getBasename(), array('.', '..'))) { + $it->next(); continue; } elseif ($file->isDir()) { rmdir($file->getPathname()); } elseif ($file->isFile() || $file->isLink()) { unlink($file->getPathname()); } + $it->next(); } if ($result = @rmdir($this->buildPath($path))) { $this->cleanMapper($path); |