Skip to content

Commit

Permalink
Ensure clients get write capability (#10872)
Browse files Browse the repository at this point in the history
When Ydoc requests to open file and encounters a timeout, it will
attempt to retry the request. At least that's the behaviour since
 #10787.
Unfortunately, the write lock on the file might be already held and
identified by the client id and actor reference. The latter is always
determined by the request and therefore spurious. The same client should
always be given the same capability, even on retries.
  • Loading branch information
hubertp authored Aug 22, 2024
1 parent 7653280 commit 6b0194c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,12 @@ class CollaborativeBuffer(
autoSave: Map[ClientId, (ContentVersion, Cancellable)]
): Unit = {
val writeCapability =
if (lockHolder.isEmpty)
Some(CapabilityRegistration(CanEdit(bufferPath)))
else
None
lockHolder match {
case Some(session) if session.clientId != rpcSession.clientId =>
None
case _ =>
Some(CapabilityRegistration(CanEdit(bufferPath)))
}
sender() ! OpenFileResponse(Right(OpenFileResult(buffer, writeCapability)))
context.become(
collaborativeEditing(
Expand Down

0 comments on commit 6b0194c

Please sign in to comment.