Skip to content

Commit 039d151

Browse files
juliusknorrbackportbot[bot]
authored andcommitted
Use write permission when possible
Signed-off-by: Julius Härtl <[email protected]>
1 parent dd40bb0 commit 039d151

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Service/DocumentService.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,13 @@ public function getFileById($fileId, $userId = null): Node {
405405
throw new NotFoundException();
406406
}
407407

408-
return $files[0];
408+
// Workaround to always open files with edit permissions if multiple occurences of
409+
// the same file id are in the user home, ideally we should also track the path of the file when opening
410+
usort($files, function (Node $a, Node $b) {
411+
return ($a->getPermissions() & Constants::PERMISSION_UPDATE) < ($b->getPermissions() & Constants::PERMISSION_UPDATE);
412+
});
413+
414+
return array_shift($files);
409415
}
410416

411417
/**

0 commit comments

Comments
 (0)