diff --git a/apps/files_trashbin/lib/Quota.php b/apps/files_trashbin/lib/Quota.php index 28eac7991f7f..94d2344e5770 100644 --- a/apps/files_trashbin/lib/Quota.php +++ b/apps/files_trashbin/lib/Quota.php @@ -55,14 +55,8 @@ public function calculateFreeSpace($trashbinSize, $user) { if ($userObject === null) { return 0; } - $quota = $this->getUserQuota($userObject); - $userFolder = \OC::$server->getUserFolder($user); - if ($userFolder === null) { - return 0; - } - - $free = $quota - $userFolder->getSize(); // remaining free space for user + $free = $this->getFreeSpace($userObject); if ($free > 0) { // does trashbin size hit purge limit with the current free space $availableSpace = ($free * $this->getPurgeLimit() / 100) - $trashbinSize; @@ -84,21 +78,27 @@ public function getPurgeLimit() { } /** - * Get user quota or free space when there is no quota set + * Get free space for the current user + * or free disk space if the current user has no quota set * * @param IUser $user - * @return int|mixed + * @return int */ - protected function getUserQuota(IUser $user) { + protected function getFreeSpace(IUser $user) { + $free = 0; $quota = \OC_Util::getUserQuota($user); if ($quota === FileInfo::SPACE_UNLIMITED) { - $quota = Filesystem::free_space('/'); + $free = Filesystem::free_space('/'); // inf or unknown free space - if ($quota < 0) { - $quota = PHP_INT_MAX; + if ($free < 0) { + $free = PHP_INT_MAX; + } + } else { + $userFolder = \OC::$server->getUserFolder($user->getUID()); + if ($userFolder !== null) { + $free = $userFolder->getFreeSpace(); } } - - return $quota; + return $free; } } diff --git a/changelog/unreleased/36494 b/changelog/unreleased/36494 new file mode 100644 index 000000000000..1bf8b88f6e5e --- /dev/null +++ b/changelog/unreleased/36494 @@ -0,0 +1,5 @@ +Bugfix: Files shared with user cause purge of the trashbin content + +Files_thrashbin app counted incoming shares on calculation of the occupied space. It caused purge of the trashbin content when trashbin_retention_obligation is auto, user has quota set and incoming shares exceed 50% of this quota. + +https://github.com/owncloud/core/pull/36494