]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check if we have a proper fileinfo
authorRobin Appelman <icewind@owncloud.com>
Mon, 23 Feb 2015 13:36:51 +0000 (14:36 +0100)
committerRobin Appelman <icewind@owncloud.com>
Wed, 25 Feb 2015 15:02:08 +0000 (16:02 +0100)
lib/private/files/node/node.php

index 4c7d32cbd0edf4335946e6191e7e0629aeb3bf59..2d46596a088ad6748677f16ffb551ccf35f62bd8 100644 (file)
  */
 namespace OC\Files\Node;
 
+use OC\Files\Filesystem;
+use OCP\Files\FileInfo;
+use OCP\Files\InvalidPathException;
+use OCP\Files\NotFoundException;
 use OCP\Files\NotPermittedException;
 
 class Node implements \OCP\Files\Node {
@@ -60,11 +64,21 @@ class Node implements \OCP\Files\Node {
        /**
         * Returns the matching file info
         *
-        * @return \OCP\Files\FileInfo
+        * @return FileInfo
+        * @throws InvalidPathException
+        * @throws NotFoundException
         */
        public function getFileInfo() {
+               if (!Filesystem::isValidPath($this->path)) {
+                       throw new InvalidPathException();
+               }
                if (!$this->fileInfo) {
-                       $this->fileInfo = $this->view->getFileInfo($this->path);
+                       $fileInfo = $this->view->getFileInfo($this->path);
+                       if ($fileInfo instanceof FileInfo) {
+                               $this->fileInfo = $fileInfo;
+                       } else {
+                               throw new NotFoundException();
+                       }
                }
                return $this->fileInfo;
        }