diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2021-08-18 08:33:47 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2021-08-18 08:38:49 +0200 |
commit | edeb8a5739142c3240c26fd3c061b14a865f781f (patch) | |
tree | b6ec15b6055aace7d5fe1100c8bf5db7584317dd /core/Command/User | |
parent | eb77a4b00884b033a15d72fb19e377ae3560b575 (diff) | |
download | nextcloud-server-edeb8a5739142c3240c26fd3c061b14a865f781f.tar.gz nextcloud-server-edeb8a5739142c3240c26fd3c061b14a865f781f.zip |
Add storage info to `user:info` command
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/Command/User')
-rw-r--r-- | core/Command/User/Info.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/Command/User/Info.php b/core/Command/User/Info.php index e6ba691a40d..377b722d293 100644 --- a/core/Command/User/Info.php +++ b/core/Command/User/Info.php @@ -26,6 +26,7 @@ namespace OC\Core\Command\User; use OC\Core\Command\Base; use OCP\IGroupManager; +use OCP\IUser; use OCP\IUserManager; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -80,6 +81,7 @@ class Info extends Base { 'enabled' => $user->isEnabled(), 'groups' => $groups, 'quota' => $user->getQuota(), + 'storage' => $this->getStorageInfo($user), 'last_seen' => date(\DateTimeInterface::ATOM, $user->getLastLogin()), // ISO-8601 'user_directory' => $user->getHome(), 'backend' => $user->getBackendClassName() @@ -87,4 +89,21 @@ class Info extends Base { $this->writeArrayInOutputFormat($input, $output, $data); return 0; } + + /** + * @param IUser $user + * @return array + */ + protected function getStorageInfo(IUser $user): array { + \OC_Util::tearDownFS(); + \OC_Util::setupFS($user->getUID()); + $storage = \OC_Helper::getStorageInfo('/'); + return [ + 'free' => $storage['free'], + 'used' => $storage['used'], + 'total' => $storage['total'], + 'relative' => $storage['relative'], + 'quota' => $storage['quota'], + ]; + } } |