diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-05-29 13:10:26 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-05-29 13:10:26 +0200 |
commit | b44192f3668ae2e8e9685479fa62a78cfc5500ba (patch) | |
tree | 151f131b64ad93db9a82e55021ac697a43620655 /lib/public | |
parent | 71a532fc4d45fafa66ce748e1296f03f57c2ea75 (diff) | |
download | nextcloud-server-b44192f3668ae2e8e9685479fa62a78cfc5500ba.tar.gz nextcloud-server-b44192f3668ae2e8e9685479fa62a78cfc5500ba.zip |
check list of users with access to the file from the bottom to the top. This way we avoid calling getFileInfo() on every dir, which creates a lot of overhead, especially for external storages
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/share.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index 03d662676c6..58e6131af58 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -133,17 +133,16 @@ class Share { * @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, $removeDuplicates = true) { + public static function getUsersSharingFile($path, $user, $includeOwner = false) { - $path_parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR)); - $path = ''; $shares = array(); $publicShare = false; $view = new \OC\Files\View('/' . $user . '/files/'); - foreach ($path_parts as $p) { - $path .= '/' . $p; - $meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path)); - $source = $meta['fileid']; + $meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path)); + $source = $meta['fileid']; + $cache = new \OC\Files\Cache\Cache($meta['storage']); + + while ($path !== 'files') { // Fetch all shares of this file path from DB $query = \OC_DB::prepare( @@ -203,6 +202,13 @@ class Share { if ($result->fetchRow()) { $publicShare = true; } + + // let's get the parent for the next round + $meta = $cache->get((int)$source); + $parent = $meta['parent']; + $parentMeta = $cache->get((int)$parent); + $path = $parentMeta['path']; + $source = $parent; } // Include owner in list of users, if requested if ($includeOwner) { |