diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2025-03-11 12:24:18 +0100 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2025-03-19 23:32:09 +0100 |
commit | 590c6a7d4b6388db8534cef58065174869a18742 (patch) | |
tree | 75194a81677bbabcdf9e21e4872a11b30dec6fe1 | |
parent | 27e1a48426ed95f4554c94eae2dd0debc183b9bb (diff) | |
download | nextcloud-server-590c6a7d4b6388db8534cef58065174869a18742.tar.gz nextcloud-server-590c6a7d4b6388db8534cef58065174869a18742.zip |
fix: skip caching lastSeenQuotaUsage for remote sharesbackport/51389/stable30
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php | 14 | ||||
-rw-r--r-- | lib/private/legacy/OC_Helper.php | 13 |
2 files changed, 22 insertions, 5 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index 0636a251dec..3e297320d15 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -283,8 +283,9 @@ class DirectoryTest extends \Test\TestCase { $storage->expects($this->any()) ->method('instanceOfStorage') ->willReturnMap([ - '\OCA\Files_Sharing\SharedStorage' => false, - '\OC\Files\Storage\Wrapper\Quota' => false, + ['\OCA\Files_Sharing\SharedStorage', false], + ['\OC\Files\Storage\Wrapper\Quota', false], + [\OCA\Files_Sharing\External\Storage::class, false], ]); $storage->expects($this->once()) @@ -314,6 +315,10 @@ class DirectoryTest extends \Test\TestCase { ->method('getRelativePath') ->willReturn('/foo'); + $this->info->expects($this->once()) + ->method('getInternalPath') + ->willReturn('/foo'); + $mountPoint->method('getMountPoint') ->willReturn('/user/files/mymountpoint'); @@ -336,6 +341,7 @@ class DirectoryTest extends \Test\TestCase { ->willReturnMap([ ['\OCA\Files_Sharing\SharedStorage', false], ['\OC\Files\Storage\Wrapper\Quota', true], + [\OCA\Files_Sharing\External\Storage::class, false], ]); $storage->expects($this->once()) @@ -358,6 +364,10 @@ class DirectoryTest extends \Test\TestCase { ->method('getMountPoint') ->willReturn($mountPoint); + $this->info->expects($this->once()) + ->method('getInternalPath') + ->willReturn('/foo'); + $mountPoint->method('getMountPoint') ->willReturn('/user/files/mymountpoint'); diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index 7db60363ff3..f26257dddeb 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -541,10 +541,17 @@ class OC_Helper { $relative = 0; } - /** @var string $ownerId */ + /* + * \OCA\Files_Sharing\External\Storage returns the cloud ID as the owner for the storage. + * It is unnecessary to query the user manager for the display name, as it won't have this information. + */ + $isRemoteShare = $storage->instanceOfStorage(\OCA\Files_Sharing\External\Storage::class); + $ownerId = $storage->getOwner($path); + $hasOwnerId = $ownerId !== false && $ownerId !== null; $ownerDisplayName = ''; - if ($ownerId) { + + if ($isRemoteShare === false && $hasOwnerId) { $ownerDisplayName = \OC::$server->getUserManager()->getDisplayName($ownerId) ?? ''; } @@ -566,7 +573,7 @@ class OC_Helper { 'mountPoint' => trim($mountPoint, '/'), ]; - if ($ownerId && $path === '/') { + if ($isRemoteShare === false && $hasOwnerId && $path === '/') { // If path is root, store this as last known quota usage for this user \OCP\Server::get(\OCP\IConfig::class)->setUserValue($ownerId, 'files', 'lastSeenQuotaUsage', (string)$relative); } |