From: Florin Peter Date: Wed, 29 May 2013 18:11:13 +0000 (+0200) Subject: fixes if cache returns false X-Git-Tag: v6.0.0alpha2~705^2~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=353d19d183b00132204de8a1798aa7f9d9caa4d9;p=nextcloud-server.git fixes if cache returns false --- diff --git a/lib/public/share.php b/lib/public/share.php index bc0e3f15c53..9a24192b4c8 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -123,25 +123,31 @@ class Share { return $path; } - + /** * @brief Find which users can access a shared item * @param $path to the file * @param $user owner of the file * @param include owner to the list of users with access to the file * @return array - * @note $path needs to be relative to user data dir, e.g. 'file.txt' + * @note $path needs to be relative to user data dir, e.g. 'file.txt' * not '/admin/data/file.txt' */ public static function getUsersSharingFile($path, $user, $includeOwner = false) { $shares = array(); $publicShare = false; + $source = '-1'; + $cache = false; + $view = new \OC\Files\View('/' . $user . '/files/'); $meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path)); - $source = $meta['fileid']; - $cache = new \OC\Files\Cache\Cache($meta['storage']); - + + if($meta !== false) { + $source = $meta['fileid']; + $cache = new \OC\Files\Cache\Cache($meta['storage']); + } + while ($source !== '-1') { // Fetch all shares of this file path from DB @@ -206,7 +212,11 @@ class Share { // let's get the parent for the next round $meta = $cache->get((int)$source); - $source = $meta['parent']; + if($meta !== false) { + $source = $meta['parent']; + } else { + $source = '-1'; + } } // Include owner in list of users, if requested if ($includeOwner) {