Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-03-02 13:54:57 +0300
committerJulius Härtl <jus@bitgrid.net>2021-03-02 13:54:57 +0300
commitd532909098f5fb8361264685a2bc44d522ba5cf2 (patch)
treeb20e4c037300761fbcf89706a055836a60e4211a /lib
parentc3391d0550117323bc640a3d455f883d71c55cd8 (diff)
Use write permission when possible
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/DocumentService.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php
index 9bff1cdcf..8a69feeaa 100644
--- a/lib/Service/DocumentService.php
+++ b/lib/Service/DocumentService.php
@@ -409,7 +409,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);
}
/**