Ensure clients get write capability (#10872)

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.
This commit is contained in:
Hubert Plociniczak 2024-08-22 18:45:14 +02:00 committed by GitHub
parent 7653280e33
commit 6b0194c98b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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(