Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,23 +355,19 @@ public function getNoteFromShare($user) {
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) {
return $note;
}
return '';
}

Expand Down
7 changes: 7 additions & 0 deletions apps/files_sharing/lib/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ private function buildSuperShares(array $allShares, \OCP\IUser $user) {
->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
Expand Down