diff options
Diffstat (limited to 'lib/private/files/node/node.php')
-rw-r--r-- | lib/private/files/node/node.php | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/lib/private/files/node/node.php b/lib/private/files/node/node.php index 536483fc89d..e5b219420cd 100644 --- a/lib/private/files/node/node.php +++ b/lib/private/files/node/node.php @@ -8,6 +8,10 @@ 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 { @@ -45,11 +49,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; } @@ -138,6 +152,8 @@ class Node implements \OCP\Files\Node { /** * @return int + * @throws InvalidPathException + * @throws NotFoundException */ public function getId() { return $this->getFileInfo()->getId(); @@ -152,6 +168,8 @@ class Node implements \OCP\Files\Node { /** * @return int + * @throws InvalidPathException + * @throws NotFoundException */ public function getMTime() { return $this->getFileInfo()->getMTime(); @@ -159,6 +177,8 @@ class Node implements \OCP\Files\Node { /** * @return int + * @throws InvalidPathException + * @throws NotFoundException */ public function getSize() { return $this->getFileInfo()->getSize(); @@ -166,6 +186,8 @@ class Node implements \OCP\Files\Node { /** * @return string + * @throws InvalidPathException + * @throws NotFoundException */ public function getEtag() { return $this->getFileInfo()->getEtag(); @@ -173,6 +195,8 @@ class Node implements \OCP\Files\Node { /** * @return int + * @throws InvalidPathException + * @throws NotFoundException */ public function getPermissions() { return $this->getFileInfo()->getPermissions(); @@ -180,6 +204,8 @@ class Node implements \OCP\Files\Node { /** * @return bool + * @throws InvalidPathException + * @throws NotFoundException */ public function isReadable() { return $this->getFileInfo()->isReadable(); @@ -187,6 +213,8 @@ class Node implements \OCP\Files\Node { /** * @return bool + * @throws InvalidPathException + * @throws NotFoundException */ public function isUpdateable() { return $this->getFileInfo()->isUpdateable(); @@ -194,6 +222,8 @@ class Node implements \OCP\Files\Node { /** * @return bool + * @throws InvalidPathException + * @throws NotFoundException */ public function isDeletable() { return $this->getFileInfo()->isDeletable(); @@ -201,11 +231,18 @@ class Node implements \OCP\Files\Node { /** * @return bool + * @throws InvalidPathException + * @throws NotFoundException */ public function isShareable() { return $this->getFileInfo()->isShareable(); } + /** + * @return bool + * @throws InvalidPathException + * @throws NotFoundException + */ public function isCreatable() { return $this->getFileInfo()->isCreatable(); } |