Repository navigation
fix(files): account for replaced files in quota checks - #65876
Open
joshtrichards wants to merge 4 commits into
Open
joshtrichards wants to merge 4 commits into
joshtrichards wants to merge 4 commits into
Conversation
Use inclusive size checks when comparing a write or copy against the remaining quota. This allows an operation whose size equals the available space, while still rejecting operations that exceed it. Signed-off-by: Josh <josh.t.richards@gmail.com>
Add regression tests for writes and transfers whose size exactly matches the remaining quota. Exercise quota-limited streams with chunked writes, and test writeStream with both known and unknown input sizes. Assisted-by: Copilot:gpt-6-luna Signed-off-by: Josh <josh.t.richards@gmail.com>
When an operation replaces an existing file with a known size inside the quota scope, credit that size against quota usage. Do not credit it against physical free space, which may not be reclaimed immediately by every storage backend. For moves, credit the existing destination but continue requiring space for the full source, since whether the source is already included in the quota total may be unknown. Signed-off-by: Josh <josh.t.richards@gmail.com>
Verify that quota checks credit known existing targets for writes, copies, and moves. Cover the conservative move behavior when the source is already included in quota usage. Assisted-by: Copilot:gpt-6-luna Signed-off-by: Josh <josh.t.richards@gmail.com>
joshtrichards
requested review from
Altahrim,
icewind1991,
provokateurin and
salmart-dev
and removed request for
a team
October 24, 2026 14:48
4 of 7 tasks
Merged
8 tasks
This branch has not been deployed
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
Preserves conservative physical free-space checks: replacement credit applies only to account quota usage.
For moves, credits the existing destination but conservatively continues requiring space for the full source, since the check cannot currently establish whether the source is already included in quota usage.
Follow-up
Quota-scope enforcement appears inconsistent across mutator operations for destinations outside
files/, including internal trash and version paths. I haven't found a convincing reason for applying the account quota differently depending on the operation:shouldApplyQuota()documents that quota applies to files underfiles/, not metadata, trash, or other paths.fopen()andmkdir()honor that distinction, whiletouch()applies its zero-space rejection unconditionally. The same scope question applies tofile_put_contents(),copy(),copyFromStorage(), andmoveFromStorage().writeStream()scope-gates its zero-space rejection, but when a size is supplied, it still compares that size against quota-limited free space for paths outsidefiles/.The changes introduced by this PR should make that easier to address separately. I considered including scope-policy changes here, but reverted them part-way through in order to keep this PR focused and avoid expanding the regression surface of the current fix.
A follow-up needs further call-site and test-coverage auditing, particularly around trash/version operations, restores, and physical-storage failures. If the differences are intentional, it should instead document why particular operations are exceptions.
Related:
TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)