Merge pull request #22451 from owncloud/use-proper-user-folder
Handles null as return code and uses proper UserFolder in trashbin
This commit is contained in:
commit
9e415a956a
|
@ -561,11 +561,12 @@ class Trashbin {
|
||||||
* @return int available free space for trash bin
|
* @return int available free space for trash bin
|
||||||
*/
|
*/
|
||||||
private static function calculateFreeSpace($trashbinSize, $user) {
|
private static function calculateFreeSpace($trashbinSize, $user) {
|
||||||
$config = \OC::$server->getConfig();
|
|
||||||
|
|
||||||
$softQuota = true;
|
$softQuota = true;
|
||||||
$quota = \OC::$server->getUserManager()->get($user)->getQuota();
|
$userObject = \OC::$server->getUserManager()->get($user);
|
||||||
$view = new \OC\Files\View('/' . $user);
|
if(is_null($userObject)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$quota = $userObject->getQuota();
|
||||||
if ($quota === null || $quota === 'none') {
|
if ($quota === null || $quota === 'none') {
|
||||||
$quota = \OC\Files\Filesystem::free_space('/');
|
$quota = \OC\Files\Filesystem::free_space('/');
|
||||||
$softQuota = false;
|
$softQuota = false;
|
||||||
|
@ -580,8 +581,11 @@ class Trashbin {
|
||||||
// calculate available space for trash bin
|
// calculate available space for trash bin
|
||||||
// subtract size of files and current trash bin size from quota
|
// subtract size of files and current trash bin size from quota
|
||||||
if ($softQuota) {
|
if ($softQuota) {
|
||||||
$rootInfo = $view->getFileInfo('/files/', false);
|
$userFolder = \OC::$server->getUserFolder($user);
|
||||||
$free = $quota - $rootInfo['size']; // remaining free space for user
|
if(is_null($userFolder)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$free = $quota - $userFolder->getSize(); // remaining free space for user
|
||||||
if ($free > 0) {
|
if ($free > 0) {
|
||||||
$availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions
|
$availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -730,7 +730,7 @@ class Server extends ServerContainer implements IServerContainer {
|
||||||
* Returns a view to ownCloud's files folder
|
* Returns a view to ownCloud's files folder
|
||||||
*
|
*
|
||||||
* @param string $userId user ID
|
* @param string $userId user ID
|
||||||
* @return \OCP\Files\Folder
|
* @return \OCP\Files\Folder|null
|
||||||
*/
|
*/
|
||||||
public function getUserFolder($userId = null) {
|
public function getUserFolder($userId = null) {
|
||||||
if ($userId === null) {
|
if ($userId === null) {
|
||||||
|
|
Loading…
Reference in New Issue