Skip to content

fix: Exclude Readme.md files from file locking in the text app#8284

Open
rikled wants to merge 6 commits intonextcloud:mainfrom
rikled:main
Open

fix: Exclude Readme.md files from file locking in the text app#8284
rikled wants to merge 6 commits intonextcloud:mainfrom
rikled:main

Conversation

@rikled
Copy link

@rikled rikled commented Feb 19, 2026

📝 Summary

This PR excludes Readme files from file locking. Without it is almost impossible to delete these files as they are opened as soon as a user visits the directory of the file. This is meant as an intermediate solution until #5597 is implemented.

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
@juliusknorr juliusknorr added bug Something isn't working 3. to review labels Feb 25, 2026
Copy link
Collaborator

@silverkszlo silverkszlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this by adding temporary debug logging and saw the following output in the nextcloud log, so seems to work :)

{"message":"Attempting to lock file","data":{"fileId":"89","fileName":"regular.md"}}
{"message":"Lock result","data":{"fileId":"89","fileName":"regular.md","isLocked":"true"}}

{"message":"Skipping lock for file","data":{"fileId":"86","fileName":"Readme.md","reason":"Readme.md exception"}}

Comment on lines +134 to +135
/** @psalm-suppress RedundantCastGivenDocblockType */
if (!$readOnly && strcasecmp((string)$file->getName(), 'Readme.md') !== 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @psalm-suppress RedundantCastGivenDocblockType */
if (!$readOnly && strcasecmp((string)$file->getName(), 'Readme.md') !== 0) {
if (!$readOnly && strcasecmp($file->getName(), 'Readme.md') !== 0) {

I think if the phpunit tests fail on that it is rather due to the file mock not having calls of getName mocked.

Probably just a matter of addding in

$file->method('getId')->willReturn($id);

$file->method('getName')->willReturn('MyFile.md');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Labels

3. to review bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

README.md is almost always locked

3 participants