diff options
author | Julius Härtl <jus@bitgrid.net> | 2021-03-30 09:21:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 09:21:24 +0300 |
commit | e5219a61e32d5ef089a91b21e116e0849c2955e2 (patch) | |
tree | e30f7610b56ae4f51bdbc08c04272f5df69bdd74 | |
parent | a85eeb22433e0869bd27f2c689472566467a37de (diff) | |
parent | 5206ec19b076c99ac9d48a647918395ee8515a2c (diff) |
Merge pull request #1514 from nextcloud/backport/1488/stable19
[stable19] Use write permission when possible
-rw-r--r-- | lib/Service/DocumentService.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index 918fe31df..edc54e0b6 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -405,7 +405,13 @@ class DocumentService { throw new NotFoundException(); } - return $files[0]; + // Workaround to always open files with edit permissions if multiple occurences of + // the same file id are in the user home, ideally we should also track the path of the file when opening + usort($files, function (Node $a, Node $b) { + return ($a->getPermissions() & Constants::PERMISSION_UPDATE) < ($b->getPermissions() & Constants::PERMISSION_UPDATE); + }); + + return array_shift($files); } /** |