Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not count shared files on trashbin free space calculation #36494

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions apps/files_trashbin/lib/Quota.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
5 changes: 5 additions & 0 deletions changelog/unreleased/36494
Original file line number Diff line number Diff line change
@@ -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