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 @@ -91,7 +91,9 @@ class FileMenuFilterIT : AbstractIT() {
filesLockingVersion = "1.0"
}

val file = OCFile("/foo.md")
val file = OCFile("/foo.md").apply {
permissions = FULL_PERMISSIONS
}

testLockingVisibilities(
capability,
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/com/nextcloud/android/files/FileLockingHelper.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2022 Álvaro Brey <alvaro@alvarobrey.com>
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.nextcloud.android.files

import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.common.network.WebdavEntry.MountType
import com.owncloud.android.lib.resources.files.model.FileLockType

object FileLockingHelper {
private val mountTypesWithoutFileOwnership = setOf(MountType.GROUP, MountType.EXTERNAL)

/**
* Checks whether the given `userId` can unlock the [OCFile].
*/
@JvmStatic
fun canUserUnlockFile(userId: String, file: OCFile): Boolean {
if (!file.isLocked || file.lockOwnerId == null || file.lockType != FileLockType.MANUAL) {
return false
}
if (!file.isLocked) return false
if (isFileOwner(userId, file)) return true
if (file.lockType == FileLockType.COLLABORATIVE) return false

return file.lockOwnerId == userId
}

private fun isFileOwner(userId: String, file: OCFile): Boolean =
file.ownerId == userId && file.mountType !in mountTypesWithoutFileOwnership
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class FileMenuFilter internal constructor(

val file = selection.firstFile

return file.isLocked || file.isFolder
return file.isLocked || file.isFolder || !file.canWrite()
}

private fun canUserUnlock(): Boolean {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
androidCommonLibraryVersion = "580a84868ae2af10b2ace13dadc083f166047493"
androidGifDrawableVersion = "1.2.32"
androidImageCropperVersion = "4.7.0"
androidLibraryVersion ="9af75eff8bd6993c92fa713feb89eaeca159c8e6"
androidLibraryVersion ="b1103fc42c"
androidOpensslVersion = "3.5.6.1"
androidPluginVersion = "9.5.1"
androidsvgVersion = "1.4"
Expand Down
8 changes: 8 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23424,6 +23424,14 @@
<sha256 value="ed27e48731e8be2cde6cac10b89e49529dfd91f8b719410505ca93bc6eed87a1" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.nextcloud" name="android-library" version="b1103fc42c">
<artifact name="android-library-b1103fc42c.aar">
<sha256 value="a9af4ab30877bf94f4ceedfd3d1e26579128692c4edaff60942ab96d3411f1f3" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
<artifact name="android-library-b1103fc42c.module">
<sha256 value="429ee877de621e66c2ba830612754fcbfa5dfad8ba6a07088c38e6d0b5ca668f" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.nextcloud" name="android-library" version="b14ecf0388338691b9442eb8535ebbf1b7b39495">
<artifact name="android-library-b14ecf0388338691b9442eb8535ebbf1b7b39495.aar">
<sha256 value="c082789596462fd14095dd191fe75884f366c01dd5dd68c9aeac3b867972a907" origin="Generated by Gradle" reason="Artifact is not signed"/>
Expand Down
Loading