From da951ba059209914849dd9a289ea3f398bbab70e Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Tue, 10 Mar 2015 16:30:13 +0100
Subject: [PATCH] Use the new IteratorDirectory instead of the fakedir wrapper

---
 apps/files_external/lib/amazons3.php                 | 5 ++---
 apps/files_external/lib/dropbox.php                  | 5 +++--
 apps/files_external/lib/google.php                   | 5 +++--
 apps/files_external/lib/sftp.php                     | 4 ++--
 apps/files_external/lib/swift.php                    | 4 ++--
 lib/private/files/objectstore/objectstorestorage.php | 5 ++---
 lib/private/files/storage/dav.php                    | 5 ++---
 lib/private/files/storage/local.php                  | 1 -
 8 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index 02a02710a14..b956a607eba 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -40,6 +40,7 @@ require 'aws-autoloader.php';
 
 use Aws\S3\S3Client;
 use Aws\S3\Exception\S3Exception;
+use Icewind\Streams\IteratorDirectory;
 
 class AmazonS3 extends \OC\Files\Storage\Common {
 
@@ -284,9 +285,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
 				$files[] = $file;
 			}
 
-			\OC\Files\Stream\Dir::register('amazons3' . $path, $files);
-
-			return opendir('fakedir://amazons3' . $path);
+			return IteratorDirectory::wrap($files);
 		} catch (S3Exception $e) {
 			\OCP\Util::logException('files_external', $e);
 			return false;
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 78219f8f06e..2d1aea1afc8 100644
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -29,6 +29,8 @@
 
 namespace OC\Files\Storage;
 
+use Icewind\Streams\IteratorDirectory;
+
 require_once __DIR__ . '/../3rdparty/Dropbox/autoload.php';
 
 class Dropbox extends \OC\Files\Storage\Common {
@@ -156,8 +158,7 @@ class Dropbox extends \OC\Files\Storage\Common {
 			foreach ($contents as $file) {
 				$files[] = basename($file['path']);
 			}
-			\OC\Files\Stream\Dir::register('dropbox'.$path, $files);
-			return opendir('fakedir://dropbox'.$path);
+			return IteratorDirectory::wrap($files);
 		}
 		return false;
 	}
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index 8199d97eacb..2ca550dfe7c 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -32,6 +32,8 @@
 
 namespace OC\Files\Storage;
 
+use Icewind\Streams\IteratorDirectory;
+
 set_include_path(get_include_path().PATH_SEPARATOR.
 	\OC_App::getAppPath('files_external').'/3rdparty/google-api-php-client/src');
 require_once 'Google/Client.php';
@@ -291,8 +293,7 @@ class Google extends \OC\Files\Storage\Common {
 				}
 				$pageToken = $children->getNextPageToken();
 			}
-			\OC\Files\Stream\Dir::register('google'.$path, $files);
-			return opendir('fakedir://google'.$path);
+			return IteratorDirectory::wrap($files);
 		} else {
 			return false;
 		}
diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php
index cbe090311a9..64bb52f3193 100644
--- a/apps/files_external/lib/sftp.php
+++ b/apps/files_external/lib/sftp.php
@@ -29,6 +29,7 @@
  *
  */
 namespace OC\Files\Storage;
+use Icewind\Streams\IteratorDirectory;
 
 /**
 * Uses phpseclib's Net_SFTP class and the Net_SFTP_Stream stream wrapper to
@@ -278,8 +279,7 @@ class SFTP extends \OC\Files\Storage\Common {
 					$dirStream[] = $file;
 				}
 			}
-			\OC\Files\Stream\Dir::register($id, $dirStream);
-			return opendir('fakedir://' . $id);
+			return IteratorDirectory::wrap($dirStream);
 		} catch(\Exception $e) {
 			return false;
 		}
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index 50f0d40805a..d8107e58fed 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -32,6 +32,7 @@
 namespace OC\Files\Storage;
 
 use Guzzle\Http\Exception\ClientErrorResponseException;
+use Icewind\Streams\IteratorDirectory;
 use OpenCloud;
 use OpenCloud\Common\Exceptions;
 use OpenCloud\OpenStack;
@@ -222,8 +223,7 @@ class Swift extends \OC\Files\Storage\Common {
 				}
 			}
 
-			\OC\Files\Stream\Dir::register('swift' . $path, $files);
-			return opendir('fakedir://swift' . $path);
+			return IteratorDirectory::wrap($files);
 		} catch (\Exception $e) {
 			\OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
 			return false;
diff --git a/lib/private/files/objectstore/objectstorestorage.php b/lib/private/files/objectstore/objectstorestorage.php
index 24398649727..a85553186ae 100644
--- a/lib/private/files/objectstore/objectstorestorage.php
+++ b/lib/private/files/objectstore/objectstorestorage.php
@@ -24,6 +24,7 @@
 
 namespace OC\Files\ObjectStore;
 
+use Icewind\Streams\IteratorDirectory;
 use OCP\Files\ObjectStore\IObjectStore;
 
 class ObjectStoreStorage extends \OC\Files\Storage\Common {
@@ -216,9 +217,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
 				$files[] = $file['name'];
 			}
 
-			\OC\Files\Stream\Dir::register('objectstore' . $path . '/', $files);
-
-			return opendir('fakedir://objectstore' . $path . '/');
+			return IteratorDirectory::wrap($files);
 		} catch (\Exception $e) {
 			\OCP\Util::writeLog('objectstore', $e->getMessage(), \OCP\Util::ERROR);
 			return false;
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
index e02f971b38b..4be587e7799 100644
--- a/lib/private/files/storage/dav.php
+++ b/lib/private/files/storage/dav.php
@@ -38,7 +38,7 @@ namespace OC\Files\Storage;
 use Exception;
 use OC\Files\Filesystem;
 use OC\Files\Stream\Close;
-use OC\Files\Stream\Dir;
+use Icewind\Streams\IteratorDirectory;
 use OC\MemCache\ArrayCache;
 use OCP\Constants;
 use OCP\Files;
@@ -211,8 +211,7 @@ class DAV extends Common {
 				$file = basename($file);
 				$content[] = $file;
 			}
-			Dir::register($id, $content);
-			return opendir('fakedir://' . $id);
+			return IteratorDirectory::wrap($content);
 		} catch (ClientHttpException $e) {
 			if ($e->getHttpStatus() === 404) {
 				$this->statCache->clear($path . '/');
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index b7272b7d1f0..3676fe69131 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -35,7 +35,6 @@
  */
 
 namespace OC\Files\Storage;
-
 /**
  * for local filestore, we only have to map the paths
  */
-- 
GitLab