aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-05-22 14:34:39 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2025-05-22 15:47:02 +0200
commit2013bbaaea17c9e4d0fb1e32d59f13facd583fe0 (patch)
treed9f012294e10867677340ad82ed482717d468afa
parentc10107bf49e6a5180239d74e20390cc22beb3145 (diff)
downloadnextcloud-server-feat/user-folder.tar.gz
nextcloud-server-feat/user-folder.zip
chore: migrate away from deprecated OC_Helper to IUserFolderfeat/user-folder
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--core/Command/User/Info.php19
-rw-r--r--lib/private/User/User.php8
-rw-r--r--lib/private/legacy/OC_Helper.php6
3 files changed, 19 insertions, 14 deletions
diff --git a/core/Command/User/Info.php b/core/Command/User/Info.php
index 220bbbf571d..d5146802986 100644
--- a/core/Command/User/Info.php
+++ b/core/Command/User/Info.php
@@ -6,10 +6,12 @@
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
-use OCP\Files\NotFoundException;
+use OC\User\NoUserException;
+use OCP\Files\IRootFolder;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Server;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -81,20 +83,13 @@ class Info extends Base {
* @return array
*/
protected function getStorageInfo(IUser $user): array {
- \OC_Util::tearDownFS();
- \OC_Util::setupFS($user->getUID());
+ $root = Server::get(IRootFolder::class);
try {
- $storage = \OC_Helper::getStorageInfo('/');
- } catch (NotFoundException $e) {
+ $userFolder = $root->getUserFolder($user->getUID());
+ return $userFolder->getUserQuota();
+ } catch (NoUserException) {
return [];
}
- return [
- 'free' => $storage['free'],
- 'used' => $storage['used'],
- 'total' => $storage['total'],
- 'relative' => $storage['relative'],
- 'quota' => $storage['quota'],
- ];
}
/**
diff --git a/lib/private/User/User.php b/lib/private/User/User.php
index 88ed0d44387..e1b6308b141 100644
--- a/lib/private/User/User.php
+++ b/lib/private/User/User.php
@@ -14,6 +14,7 @@ use OC\Hooks\Emitter;
use OCP\Accounts\IAccountManager;
use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\IRootFolder;
use OCP\Group\Events\BeforeUserRemovedEvent;
use OCP\Group\Events\UserRemovedEvent;
use OCP\IAvatarManager;
@@ -25,6 +26,7 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserBackend;
use OCP\Notification\IManager as INotificationManager;
+use OCP\Server;
use OCP\User\Backend\IGetHomeBackend;
use OCP\User\Backend\IPasswordHashBackend;
use OCP\User\Backend\IProvideAvatarBackend;
@@ -592,7 +594,11 @@ class User implements IUser {
$this->config->setUserValue($this->uid, 'files', 'quota', $quota);
$this->triggerChange('quota', $quota, $oldQuota);
}
- \OC_Helper::clearStorageInfo('/' . $this->uid . '/files');
+
+ // clear the quota cache
+ $root = Server::get(IRootFolder::class);
+ $userFolder = $root->getUserFolder($this->uid);
+ $userFolder->getUserQuota(false);
}
public function getManagerUids(): array {
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 4388f775623..2d12e2df510 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -219,6 +219,7 @@ class OC_Helper {
* @psalm-suppress LessSpecificReturnStatement Legacy code outputs weird types - manually validated that they are correct
* @return StorageInfo
* @throws \OCP\Files\NotFoundException
+ * @deprecated 32.0.0 use \OCP\Files\IUserFolder::getUserQuota
*/
public static function getStorageInfo($path, $rootInfo = null, $includeMountPoints = true, $useCache = true) {
if (!self::$cacheFactory) {
@@ -281,7 +282,7 @@ class OC_Helper {
// TODO: need a better way to get total space from storage
if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')) {
- /** @var \OC\Files\Storage\Wrapper\Quota $storage */
+ /** @var \OC\Files\Storage\Wrapper\Quota $sourceStorage */
$quota = $sourceStorage->getQuota();
}
try {
@@ -403,6 +404,9 @@ class OC_Helper {
];
}
+ /**
+ * @deprecated 32.0.0
+ */
public static function clearStorageInfo(string $absolutePath): void {
/** @var ICacheFactory $cacheFactory */
$cacheFactory = \OC::$server->get(ICacheFactory::class);