Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ object FileLockingHelper {
if (!file.isLocked || file.lockOwnerId == null || file.lockType != FileLockType.MANUAL) {
return false
}
return file.lockOwnerId == userId
// Lock owner can always unlock. The file owner can as well: server-side
// LockService::canUnlock allows TYPE_USER locks for the file owner.
return file.lockOwnerId == userId || file.ownerId == userId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ class FileLockingHelperTest {
Assert.assertFalse(FileLockingHelper.canUserUnlockFile(USER_NAME, file))
}

@Test
fun fileOwnerCanUnlockLockOfAnotherClient() {
val file = OCFile("/foo.md").apply {
isLocked = true
lockOwnerId = "text"
lockType = FileLockType.MANUAL
ownerId = USER_NAME
}
Assert.assertTrue(FileLockingHelper.canUserUnlockFile(USER_NAME, file))
}

@Test
fun typeNotManual_cannotUnlock() {
val file = OCFile("/foo.md").apply {
Expand Down