Skip to content

Commit

Permalink
Merge pull request nextcloud#27107 from nextcloud/backport/27043/stab…
Browse files Browse the repository at this point in the history
…le21
  • Loading branch information
skjnldsv authored Jul 1, 2021
2 parents 053e115 + 3775b86 commit 91af4e2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
*/

use bantu\IniGetWrapper\IniGetWrapper;
use OCP\Files\Mount\IMountPoint;
use OCP\IUser;
use Symfony\Component\Process\ExecutableFinder;

/**
Expand Down Expand Up @@ -518,7 +520,7 @@ public static function getStorageInfo($path, $rootInfo = null) {
$quota = OC_Util::getUserQuota($user);
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
// always get free space / total space from root + mount points
return self::getGlobalStorageInfo($quota);
return self::getGlobalStorageInfo($quota, $user, $mount);
}
}

Expand Down Expand Up @@ -570,11 +572,8 @@ public static function getStorageInfo($path, $rootInfo = null) {

/**
* Get storage info including all mount points and quota
*
* @param int $quota
* @return array
*/
private static function getGlobalStorageInfo($quota) {
private static function getGlobalStorageInfo(int $quota, IUser $user, IMountPoint $mount): array {
$rootInfo = \OC\Files\Filesystem::getFileInfo('', 'ext');
$used = $rootInfo['size'];
if ($used < 0) {
Expand All @@ -594,12 +593,22 @@ private static function getGlobalStorageInfo($quota) {
$relative = 0;
}

if (substr_count($mount->getMountPoint(), '/') < 3) {
$mountPoint = '';
} else {
[,,,$mountPoint] = explode('/', $mount->getMountPoint(), 4);
}

return [
'free' => $free,
'used' => $used,
'total' => $total,
'relative' => $relative,
'quota' => $quota
'quota' => $quota,
'owner' => $user->getUID(),
'ownerDisplayName' => $user->getDisplayName(),
'mountType' => $mount->getMountType(),
'mountPoint' => trim($mountPoint, '/'),
];
}

Expand Down

0 comments on commit 91af4e2

Please sign in to comment.