Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ public function testGetQuotaInfoUnlimited(): void {
$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())
Expand Down Expand Up @@ -314,6 +315,10 @@ public function testGetQuotaInfoUnlimited(): void {
->method('getRelativePath')
->willReturn('/foo');

$this->info->expects($this->once())
->method('getInternalPath')
->willReturn('/foo');

$mountPoint->method('getMountPoint')
->willReturn('/user/files/mymountpoint');

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

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

$this->info->expects($this->once())
->method('getInternalPath')
->willReturn('/foo');

$mountPoint->method('getMountPoint')
->willReturn('/user/files/mymountpoint');

Expand Down
13 changes: 10 additions & 3 deletions lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,17 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
$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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OC\\User\\Manager::getDisplayName(): Argument #1 ($uid) must be of type string, null given, called in \/home\/runner\/work\/server\/server\/lib\/private\/legacy\/OC_Helper.php on line 554 in file '\/home\/runner\/work\/server\/server\/lib\/private\/User\/Manager.php' line 156

Integration tests were failing because getOwner may return null for Nextcloud 30.
This was improved for 31 with: #48094.

$ownerDisplayName = '';
if ($ownerId) {

if ($isRemoteShare === false && $hasOwnerId) {
$ownerDisplayName = \OC::$server->getUserManager()->getDisplayName($ownerId) ?? '';
}

Expand All @@ -566,7 +573,7 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
'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);
}
Expand Down
Loading