fix(files): do not reject ownership transfer when free space is unlimited - #64020
Open
jo23sh wants to merge 1 commit into
Open
fix(files): do not reject ownership transfer when free space is unlimited#64020jo23sh wants to merge 1 commit into
jo23sh wants to merge 1 commit into
Conversation
…ited View::free_space() can return negative sentinels (SPACE_UNKNOWN, SPACE_UNLIMITED, SPACE_NOT_COMPUTED) instead of an amount of free space. The quota check in analyse() exempted only SPACE_UNKNOWN, so SPACE_UNLIMITED (-3) fell through the guard: `$size > -3` is true for any non-empty source, and the transfer aborted with "Target user does not have enough free space available." This is reachable on instances using object storage as primary storage, where ObjectStoreStorage::free_space() returns SPACE_UNLIMITED unless a totalSizeLimit is configured, and Quota::free_space() passes that through unchanged for a destination user with no quota set. The transfer then fails precisely because the target has unlimited space. Exempt SPACE_UNLIMITED alongside SPACE_UNKNOWN. SPACE_NOT_COMPUTED (-1) keeps rejecting: Quota::free_space() returns it when a quota is set but the used size could not be read, so there is a finite limit that should still be respected. Signed-off-by: Josua Hunziker <josh@o23.ch> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jo23sh
requested review from
CarlSchwan,
leftybournes,
salmart-dev and
sorbaugh
and removed request for
a team
September 4, 2026 12:21
susnux
reviewed
Sep 4, 2026
| // A negative return value is a sentinel (SPACE_UNKNOWN, SPACE_UNLIMITED or | ||
| // SPACE_NOT_COMPUTED) rather than an amount of free space, so there is no | ||
| // finite limit to compare the size against. | ||
| if ($freeSpace >= 0 && $size > $freeSpace) { |
Contributor
There was a problem hiding this comment.
I wonder if we should allow SPACE_NOT_COMPUTED as this could mean this overflows the quota, no?
Author
There was a problem hiding this comment.
Good catch, you're right. Quota::free_space() only returns SPACE_NOT_COMPUTED on the branch where a quota is set and the cached size couldn't be read — so it means "there is a limit, headroom unknown", not "no limit". Amended to exempt only SPACE_UNKNOWN and SPACE_UNLIMITED.
Side note: the quota wrapper itself treats any negative as "allow" (copy(), moveFromStorage(), fopen()), so -1 isn't enforced downstream either — but failing closed in the pre-check is cheap.
jo23sh
force-pushed
the
fix/transfer-ownership-free-space-sentinel
branch
from
September 5, 2026 05:49
0e73553 to
4131c46
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.
Fixes #64019
The quota check in
analyse()exempted onlySPACE_UNKNOWN(-2), butfree_space()also returnsSPACE_UNLIMITED(-3). A quota-less user on object-store primary storage gets-3, so$size > -3was true for any non-empty source and the transfer aborted with "Target user does not have enough free space available."Exempt
SPACE_UNLIMITEDas well.SPACE_NOT_COMPUTED(-1) keeps rejecting:Quota::free_space()returns it when a quota is set but the used size could not be read, so there is a finite limit that should still be respected.