diff options
author | Dariusz Olszewski <starypatyk@users.noreply.github.com> | 2022-10-07 23:24:12 +0200 |
---|---|---|
committer | Dariusz Olszewski <starypatyk@users.noreply.github.com> | 2022-10-07 23:24:12 +0200 |
commit | 255d1dd68644f02739dd4bbf377893ecdb9b8629 (patch) | |
tree | 9dcd4bc3bb33ed1d1586dc1499d701807bd689f6 | |
parent | 63474360a8270c98528665129ba0f85d8c2ea354 (diff) | |
download | nextcloud-server-255d1dd68644f02739dd4bbf377893ecdb9b8629.tar.gz nextcloud-server-255d1dd68644f02739dd4bbf377893ecdb9b8629.zip |
Read notes from share already loaded into memory
Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Node.php | 26 | ||||
-rw-r--r-- | apps/files_sharing/lib/MountProvider.php | 7 |
2 files changed, 18 insertions, 15 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 5fb811ad1ab..e1cbdeac7e0 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -355,23 +355,19 @@ abstract class Node implements \Sabre\DAV\INode { return ''; } - $types = [ - IShare::TYPE_USER, - IShare::TYPE_GROUP, - IShare::TYPE_CIRCLE, - IShare::TYPE_ROOM - ]; - - foreach ($types as $shareType) { - $shares = $this->shareManager->getSharedWith($user, $shareType, $this, -1); - foreach ($shares as $share) { - $note = $share->getNote(); - if ($share->getShareOwner() !== $user && !empty($note)) { - return $note; - } - } + // Retrieve note from the share object already loaded into + // memory, to avoid additional database queries. + $storage = $this->getNode()->getStorage(); + if (!$storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { + return ''; } + /** @var \OCA\Files_Sharing\SharedStorage $storage */ + $share = $storage->getShare(); + $note = $share->getNote(); + if ($share->getShareOwner() !== $user && !empty($note)) { + return $note; + } return ''; } diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 954c9cf70e6..a9705e94906 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -229,6 +229,13 @@ class MountProvider implements IMountProvider { ->setShareType($shares[0]->getShareType()) ->setTarget($shares[0]->getTarget()); + // Gather notes from all the shares. + // Since these are readly available here, storing them + // enables the DAV FilesPlugin to avoid executing many + // DB queries to retrieve the same information. + $allNotes = implode("\n", array_map(function ($sh) { return $sh->getNote(); }, $shares)); + $superShare->setNote($allNotes); + // use most permissive permissions // this covers the case where there are multiple shares for the same // file e.g. from different groups and different permissions |