Skip to content

Show unlock action for the file owner - #17838

Open
falkloewert wants to merge 1 commit into
nextcloud:masterfrom
falkloewert:fix/unlock-file-owner
Open

falkloewert wants to merge 1 commit into
nextcloud:masterfrom
falkloewert:fix/unlock-file-owner

Conversation

@falkloewert

Copy link
Copy Markdown

Fixes #17837

Summary

The "Unlock file" entry was only shown when the current user owns the lock (lockOwnerId == userId). The server also allows the file owner to unlock TYPE_USER locks — OCA\FilesLock\Service\LockService::canUnlock():

if ($request->getType() === ILock::TYPE_USER && $isFileOwner) {
    return;
}

Without this, a stale lock created by another client (e.g. the Text app, lock owner text) cannot be released from the app at all; with the default lock_timeout = -1 it never expires.

Change: FileLockingHelper.canUserUnlockFile() now also accepts file.ownerId == userId.

Known limitation: for group folders and external storage the server deliberately skips the file-owner check (MountProvider allowlist in canUnlock), so the client cannot mirror the rule exactly there; the action can then fail with the existing error snackbar.

🖼️ Screenshots

Not applicable — the only visible difference is an additional entry in the file overflow menu.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed — one added case; existing cases still pass (FileLockingHelperTest, 5 tests)
  • 🔙 Backport requests are created or not needed: not needed
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?): "Unlock a file locked by another client"

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI — assistant-generated patch, reviewed and tested by me.

The server allows the owner of a file to unlock TYPE_USER locks
(LockService::canUnlock), so a stale lock created by another client -
e.g. the Text app, whose locks have the owner "text" - can be released
by the user. The client only offered the action when the lock owner
matched the current user, leaving users without a way to clear such
locks until the lock timeout expires (which defaults to unlimited).

Signed-off-by: Falk Loewert <falk@co-sinus.de>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Lock owned by another client (e.g. Text app) cannot be unlocked from the app

1 participant