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>
| // 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) { |
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?
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.
0e73553 to
4131c46
Compare
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
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.