Allow quota write streams with unknown free space#61706
Open
veryCrunchy wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes false NotEnoughSpaceException failures during quota-wrapped writeStream() writes when the underlying storage reports “unknown/unlimited” free space (negative sentinel), which particularly affects chunked WebDAV uploads to uploads/... on S3 primary storage.
Changes:
- Update
OC\Files\Storage\Wrapper\Quota::writeStream()to allow known-size writes whenfree_space()is negative (unknown/unlimited), aligning with other quota wrapper write paths. - Add a PHPUnit regression test covering a known-size stream write to an
uploads/...path when the wrapped storage reports unknown free space.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/private/Files/Storage/Wrapper/Quota.php | Treat negative free_space() as allowed in writeStream() to avoid false “insufficient space” on storages that can’t report free space. |
| tests/lib/Files/Storage/Wrapper/QuotaTest.php | Adds regression coverage for writing a sized stream to uploads/... when wrapped storage reports unknown free space. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
|
/backport to stable34 |
Signed-off-by: veryCrunchy <me@verycrunchy.dev>
c2fe550 to
93995b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR allows quota-wrapped
writeStream()calls to proceed when the reported free space is unknown.With S3 primary object storage and a finite user quota, chunked WebDAV uploads can fail while writing chunks to the DAV upload staging path under
uploads/.... For upload staging paths,Quota::free_space()delegates to the wrapped storage. Object-store-backed storage can report free space as unknown, butQuota::writeStream()currently compares the known stream size directly against that value and can raiseNotEnoughSpaceExceptioneven though the user's destination quota has enough available space.This changes
Quota::writeStream()to treat unknown free space consistently with other quota wrapper write paths such asfile_put_contents(),copy(),copyFromStorage(), andmoveFromStorage().A regression test covers writing a known-size stream to an
uploads/...path when the wrapped storage reports unknown free space.AI assistance was used to help inspect logs, reason through the relevant code path, draft the regression test, and organize validation. I prepared this patch after reproducing the issue on an affected Nextcloud instance. After the fix was drafted and tested locally, I found the existing report in #61488 and linked this PR to that issue.
Validation performed:
Result:
Manual validation was also performed against an affected Nextcloud instance with S3 primary storage and a finite user quota:
413 Request Entity Too Large/Insufficient space.413 Insufficient spaceerrors after applying the fix.stable34. I checkedstable33,stable32,stable31, andstable30; those branches do not contain theQuota::writeStream()override with the vulnerable$size < $freecomparison.TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)