Skip to content

Commit d5e9bd8

Browse files
max-nextcloudbackportbot[bot]
authored andcommitted
chore(performance): only check permissions when changing content
chore(performance): only check permissions when changing content Avoid setting up the file system for read only shares. Also clarify the behavior: Updates are silently dropped as they were before. Previously `stepsToInsert` would always be empty for readonly requests, due to the continue in the loop collecting the steps. So there was no way to trigger the ``` NotPermittedException('Read-only client tries to push steps with changes') ``` Keep this behavior for now so we can backport this commit. Clients on readonly shares regularly push updates to the server to update their awareness state - i.e. let others know they are still around. These requests trigger the addStep function even if they do not actually change the content of the file. Signed-off-by: Max <max@nextcloud.com>
1 parent abcb270 commit d5e9bd8

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

lib/Service/DocumentService.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,11 @@ public function writeDocumentState(int $documentId, string $content): void {
207207
*/
208208
public function addStep(Document $document, Session $session, array $steps, int $version, ?int $recoveryAttempt, ?string $shareToken): array {
209209
$documentId = $session->getDocumentId();
210-
$file = $this->getFileForSession($session, $shareToken);
211-
$readOnly = $this->isReadOnly($file, $shareToken);
212210
$stepsToInsert = [];
213211
$stepsIncludeQuery = false;
214212
$documentState = null;
215213
foreach ($steps as $step) {
216214
$message = YjsMessage::fromBase64($step);
217-
if ($readOnly && $message->isUpdate()) {
218-
continue;
219-
}
220215
// Filter out query steps as they would just trigger clients to send their steps again
221216
if ($message->getYjsMessageType() === YjsMessage::YJS_MESSAGE_SYNC && $message->getYjsSyncType() === YjsMessage::YJS_MESSAGE_SYNC_STEP1) {
222217
$stepsIncludeQuery = true;
@@ -225,10 +220,10 @@ public function addStep(Document $document, Session $session, array $steps, int
225220
}
226221
}
227222
if (count($stepsToInsert) > 0) {
228-
if ($readOnly) {
229-
throw new NotPermittedException('Read-only client tries to push steps with changes');
223+
$file = $this->getFileForSession($session, $shareToken);
224+
if (!$this->isReadOnly($file, $shareToken)) {
225+
$this->insertSteps($document, $session, $stepsToInsert);
230226
}
231-
$this->insertSteps($document, $session, $stepsToInsert);
232227
}
233228

234229
// By default, send all steps the user has not received yet.

0 commit comments

Comments
 (0)