Skip to content

Commit

Permalink
Use write permission when possible
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr authored and backportbot[bot] committed Mar 11, 2021
1 parent dd40bb0 commit 039d151
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Service/DocumentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,13 @@ public function getFileById($fileId, $userId = null): Node {
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);
}

/**
Expand Down

0 comments on commit 039d151

Please sign in to comment.