diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 23 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 24 |
2 files changed, 19 insertions, 28 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 74f3e953a72..7719a1e6be3 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -641,7 +641,7 @@ class DefaultShareProvider implements IShareProvider { return $share; } - public function getSharesInFolder($userId, Folder $node, $reshares) { + public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('s.*', 'f.fileid', 'f.path', 'f.permissions AS f_permissions', 'f.storage', 'f.path_hash', @@ -682,12 +682,21 @@ class DefaultShareProvider implements IShareProvider { }, $childMountNodes); $qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')); - $qb->andWhere( - $qb->expr()->orX( - $qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())), - $qb->expr()->in('f.fileid', $qb->createParameter('chunk')) - ) - ); + if ($shallow) { + $qb->andWhere( + $qb->expr()->orX( + $qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())), + $qb->expr()->in('f.fileid', $qb->createParameter('chunk')) + ) + ); + } else { + $qb->andWhere( + $qb->expr()->orX( + $qb->expr()->like('f.path', $qb->createNamedParameter($this->dbConn->escapeLikeParameter($node->getInternalPath()) . '/%')), + $qb->expr()->in('f.fileid', $qb->createParameter('chunk')) + ) + ); + } $qb->orderBy('id'); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index fd1a27af8cf..46f256df54d 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1303,11 +1303,11 @@ class Manager implements IManager { return $provider->move($share, $recipientId); } - public function getSharesInFolder($userId, Folder $node, $reshares = false) { + public function getSharesInFolder($userId, Folder $node, $reshares = false, $shallow = true) { $providers = $this->factory->getAllProviders(); - return array_reduce($providers, function ($shares, IShareProvider $provider) use ($userId, $node, $reshares) { - $newShares = $provider->getSharesInFolder($userId, $node, $reshares); + return array_reduce($providers, function ($shares, IShareProvider $provider) use ($userId, $node, $reshares, $shallow) { + $newShares = $provider->getSharesInFolder($userId, $node, $reshares, $shallow); foreach ($newShares as $fid => $data) { if (!isset($shares[$fid])) { $shares[$fid] = []; @@ -1319,24 +1319,6 @@ class Manager implements IManager { }, []); } - public function getSharesInFolderRecursive(string $userId, Folder $node, $reshares = false) { - $shares = $this->getSharesInFolder($userId, $node, $reshares); - - foreach ($node->getDirectoryListing() as $subnode) { - if (!$subnode instanceof Folder) { - continue; - } - - $subShares = $this->getSharesInFolderRecursive($userId, $subnode, $reshares); - - foreach ($subShares as $fileId => $subSharesForFile) { - $shares[$fileId] = array_merge($shares[$fileId] ?? [], $subSharesForFile); - } - } - - return $shares; - } - /** * @inheritdoc */ |