Skip to content

Commit a0cca3a

Browse files
committed
fix: skip caching lastSeenQuotaUsage for remote shares
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
1 parent 10376eb commit a0cca3a

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ public function testGetQuotaInfoUnlimited(): void {
283283
$storage->expects($this->any())
284284
->method('instanceOfStorage')
285285
->willReturnMap([
286-
'\OCA\Files_Sharing\SharedStorage' => false,
287-
'\OC\Files\Storage\Wrapper\Quota' => false,
286+
['\OCA\Files_Sharing\SharedStorage', false],
287+
['\OC\Files\Storage\Wrapper\Quota', false],
288+
[\OCA\Files_Sharing\External\Storage::class, false],
288289
]);
289290

290291
$storage->expects($this->once())
@@ -314,6 +315,10 @@ public function testGetQuotaInfoUnlimited(): void {
314315
->method('getRelativePath')
315316
->willReturn('/foo');
316317

318+
$this->info->expects($this->once())
319+
->method('getInternalPath')
320+
->willReturn('/foo');
321+
317322
$mountPoint->method('getMountPoint')
318323
->willReturn('/user/files/mymountpoint');
319324

@@ -336,6 +341,7 @@ public function testGetQuotaInfoSpecific(): void {
336341
->willReturnMap([
337342
['\OCA\Files_Sharing\SharedStorage', false],
338343
['\OC\Files\Storage\Wrapper\Quota', true],
344+
[\OCA\Files_Sharing\External\Storage::class, false],
339345
]);
340346

341347
$storage->expects($this->once())
@@ -358,6 +364,10 @@ public function testGetQuotaInfoSpecific(): void {
358364
->method('getMountPoint')
359365
->willReturn($mountPoint);
360366

367+
$this->info->expects($this->once())
368+
->method('getInternalPath')
369+
->willReturn('/foo');
370+
361371
$mountPoint->method('getMountPoint')
362372
->willReturn('/user/files/mymountpoint');
363373

lib/private/legacy/OC_Helper.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,17 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
541541
$relative = 0;
542542
}
543543

544-
/** @var string $ownerId */
544+
/*
545+
* \OCA\Files_Sharing\External\Storage returns the cloud ID as the owner for the storage.
546+
* It is unnecessary to query the user manager for the display name, as it won't have this information.
547+
*/
548+
$isRemoteShare = $storage->instanceOfStorage(\OCA\Files_Sharing\External\Storage::class);
549+
545550
$ownerId = $storage->getOwner($path);
551+
$hasOwnerId = $ownerId !== false && $ownerId !== null;
546552
$ownerDisplayName = '';
547-
if ($ownerId) {
553+
554+
if ($isRemoteShare === false && $hasOwnerId) {
548555
$ownerDisplayName = \OC::$server->getUserManager()->getDisplayName($ownerId) ?? '';
549556
}
550557

@@ -566,7 +573,7 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
566573
'mountPoint' => trim($mountPoint, '/'),
567574
];
568575

569-
if ($ownerId && $path === '/') {
576+
if ($isRemoteShare === false && $hasOwnerId && $path === '/') {
570577
// If path is root, store this as last known quota usage for this user
571578
\OCP\Server::get(\OCP\IConfig::class)->setUserValue($ownerId, 'files', 'lastSeenQuotaUsage', (string)$relative);
572579
}

0 commit comments

Comments
 (0)