diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-09-12 14:57:15 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-05 11:00:16 +0200 |
commit | ac38a3a654df909d2c0c9d7c4d84e8e5ea2c587a (patch) | |
tree | 3986315ba299b88f1952cf44358e49ea031d919d /lib | |
parent | 5d8b941fea23f09586b825324d0dccd39284bc26 (diff) | |
download | nextcloud-server-ac38a3a654df909d2c0c9d7c4d84e8e5ea2c587a.tar.gz nextcloud-server-ac38a3a654df909d2c0c9d7c4d84e8e5ea2c587a.zip |
Add Tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/AppData/AppData.php | 23 | ||||
-rw-r--r-- | lib/private/Files/SimpleFS/SimpleFolder.php | 15 |
2 files changed, 26 insertions, 12 deletions
diff --git a/lib/private/Files/AppData/AppData.php b/lib/private/Files/AppData/AppData.php index f2180a48e61..270e834b8e5 100644 --- a/lib/private/Files/AppData/AppData.php +++ b/lib/private/Files/AppData/AppData.php @@ -28,10 +28,11 @@ use OCP\Files\IAppData; use OCP\Files\IRootFolder; use OCP\Files\Folder; use OC\SystemConfig; +use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -class AppData extends SimpleRoot implements IAppData { +class AppData implements IAppData { /** @var IRootFolder */ private $rootFolder; @@ -42,6 +43,9 @@ class AppData extends SimpleRoot implements IAppData { /** @var string */ private $appId; + /** @var Folder */ + private $folder; + /** * AppData constructor. * @@ -97,9 +101,6 @@ class AppData extends SimpleRoot implements IAppData { return $this->folder; } - /** - * @inheritdoc - */ public function getFolder($name) { $node = $this->getAppDataFolder()->get($name); @@ -107,9 +108,6 @@ class AppData extends SimpleRoot implements IAppData { return new SimpleFolder($node); } - /** - * @inheritdoc - */ public function newFolder($name) { $folder = $this->getAppDataFolder()->newFolder($name); @@ -119,10 +117,15 @@ class AppData extends SimpleRoot implements IAppData { public function getDirectoryListing() { $listing = $this->getAppDataFolder()->getDirectoryListing(); - $fileListing = array_map(function(Node $file) { - return new SimpleFolder($file); + $fileListing = array_map(function(Node $folder) { + if ($folder instanceof Folder) { + return new SimpleFolder($folder); + } + return null; }, $listing); - return $fileListing; + $fileListing = array_filter($fileListing); + + return array_values($fileListing); } } diff --git a/lib/private/Files/SimpleFS/SimpleFolder.php b/lib/private/Files/SimpleFS/SimpleFolder.php index 4ee61f0eec9..8ce6c013c1f 100644 --- a/lib/private/Files/SimpleFS/SimpleFolder.php +++ b/lib/private/Files/SimpleFS/SimpleFolder.php @@ -22,8 +22,10 @@ */ namespace OC\Files\SimpleFS; +use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\Node; +use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFolder; class SimpleFolder implements ISimpleFolder { @@ -48,10 +50,15 @@ class SimpleFolder implements ISimpleFolder { $listing = $this->folder->getDirectoryListing(); $fileListing = array_map(function(Node $file) { - return new SimpleFile($file); + if ($file instanceof File) { + return new SimpleFile($file); + } + return null; }, $listing); - return $fileListing; + $fileListing = array_filter($fileListing); + + return array_values($fileListing); } public function delete() { @@ -61,6 +68,10 @@ class SimpleFolder implements ISimpleFolder { public function getFile($name) { $file = $this->folder->get($name); + if (!($file instanceof File)) { + throw new NotFoundException(); + } + return new SimpleFile($file); } |