From 4131c467c2fae567d603907e360296d333d7b196 Mon Sep 17 00:00:00 2001 From: Josua Hunziker Date: Fri, 4 Sep 2026 12:19:19 +0000 Subject: [PATCH] fix(files): do not reject ownership transfer when free space is unlimited 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 Co-Authored-By: Claude Opus 5 (1M context) --- apps/files/lib/Service/OwnershipTransferService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/files/lib/Service/OwnershipTransferService.php b/apps/files/lib/Service/OwnershipTransferService.php index 63045e79a826f..a9f88ec9ce109 100644 --- a/apps/files/lib/Service/OwnershipTransferService.php +++ b/apps/files/lib/Service/OwnershipTransferService.php @@ -264,7 +264,9 @@ protected function analyse( } $size = $sourceFileInfo->getSize(false); $freeSpace = $view->free_space($destinationUid . '/files/'); - if ($size > $freeSpace && $freeSpace !== FileInfo::SPACE_UNKNOWN) { + // SPACE_UNKNOWN and SPACE_UNLIMITED mean there is no finite limit to compare against. + // SPACE_NOT_COMPUTED means a quota is set but its headroom is unknown, so it still rejects. + if ($freeSpace !== FileInfo::SPACE_UNKNOWN && $freeSpace !== FileInfo::SPACE_UNLIMITED && $size > $freeSpace) { throw new TransferOwnershipException('Target user does not have enough free space available.', 1); }