Skip to content

fix(dav): release part-file lock when an upload fails#61863

Merged
CarlSchwan merged 1 commit into
masterfrom
fix/release-lock-failed-upload
Jul 16, 2026
Merged

fix(dav): release part-file lock when an upload fails#61863
CarlSchwan merged 1 commit into
masterfrom
fix/release-lock-failed-upload

Conversation

@solracsf

@solracsf solracsf commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Directory::createFile() takes a shared lock on the target file and an exclusive lock on the <name>.upload.part path before calling File::put(), but only released them on the success path. If the upload throws or is interrupted, both locks are left behind.

A leftover exclusive part-file lock causes every later upload to the same path to fail with 423 Locked. Because it persists until the request-scoped cleanup runs, or up to the lock TTL (default 1h) if the PHP worker is killed mid-request, one failed upload can block that file for a long time. The web uploader retries 423, so it just keeps hitting the same lock.

This wraps put() in try/finally so the locks are always released.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@solracsf
solracsf requested review from come-nc and icewind1991 July 7, 2026 08:00
@come-nc come-nc added this to the Nextcloud 35 milestone Jul 7, 2026

@come-nc come-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. Is that still a draft?

Comment thread apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php Outdated
@solracsf
solracsf force-pushed the fix/release-lock-failed-upload branch from 91dfc0d to 88e6e4d Compare July 7, 2026 09:49
@solracsf
solracsf marked this pull request as ready for review July 7, 2026 09:49
@solracsf
solracsf requested a review from a team as a code owner July 7, 2026 09:49
@solracsf
solracsf requested review from ArtificialOwl, leftybournes and salmart-dev and removed request for a team July 7, 2026 09:49
@solracsf solracsf self-assigned this Jul 7, 2026
@solracsf

solracsf commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/backport to stable34

@solracsf

solracsf commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/backport to stable33

@solracsf

solracsf commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

/backport to stable32

@susnux susnux added the community pull requests from community label Jul 7, 2026
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
solracsf force-pushed the fix/release-lock-failed-upload branch from 88e6e4d to e463fc9 Compare July 7, 2026 14:46
Comment thread apps/dav/lib/Connector/Sabre/Directory.php
@CarlSchwan
CarlSchwan merged commit 443d90f into master Jul 16, 2026
257 of 266 checks passed
@CarlSchwan
CarlSchwan deleted the fix/release-lock-failed-upload branch July 16, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug community pull requests from community feature: dav

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants