Merge pull request #8377 from youngguns-nl/issue_8376

RecursiveDirectoryIterator does not work on NFS
This commit is contained in:
Vincent Petry 2014-05-02 18:45:09 +02:00
commit 9e18be6422
3 changed files with 29 additions and 3 deletions

View File

@ -883,11 +883,19 @@ class Trashbin {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root), \RecursiveIteratorIterator::CHILD_FIRST);
$size = 0;
foreach ($iterator as $path) {
/**
* RecursiveDirectoryIterator on an NFS path isn't iterable with foreach
* This bug is fixed in PHP 5.5.9 or before
* See #8376
*/
$iterator->rewind();
while ($iterator->valid()) {
$path = $iterator->current();
$relpath = substr($path, strlen($root) - 1);
if (!$view->is_dir($relpath)) {
$size += $view->filesize($relpath);
}
$iterator->next();
}
return $size;
}

View File

@ -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) {

View File

@ -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);