Skip to content

Commit

Permalink
Merge pull request #41059 from owncloud/revert_41014
Browse files Browse the repository at this point in the history
Revert "Don't mount shares with failed underlying storages"
  • Loading branch information
jvillafanez authored and DeepDiver1975 committed Nov 16, 2023
1 parent d08083d commit 1781f0b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 51 deletions.
9 changes: 1 addition & 8 deletions apps/files_sharing/lib/MountProvider.php
Expand Up @@ -82,7 +82,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
$mounts = [];
foreach ($superShares as $share) {
try {
$shareMount = new SharedMount(
$mounts[] = new SharedMount(
'\OCA\Files_Sharing\SharedStorage',
$mounts,
[
Expand All @@ -94,13 +94,6 @@ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
],
$storageFactory
);

$shareStorage = $shareMount->getStorage();
if ($shareStorage !== null && $shareStorage->getPermissions('') !== 0) {
// permissions = 0 implies that the underlying storage
// being shared isn't valid
$mounts[] = $shareMount;
}
} catch (\Exception $e) {
$this->logger->logException($e);
$this->logger->error('Error while trying to create shared mount');
Expand Down
43 changes: 0 additions & 43 deletions apps/files_sharing/tests/MountProviderTest.php
Expand Up @@ -22,7 +22,6 @@

namespace OCA\Files_Sharing\Tests;

use OC\Files\Storage\Storage;
use OCA\Files_Sharing\MountProvider;
use OCP\Files\Storage\IStorageFactory;
use OCP\IConfig;
Expand Down Expand Up @@ -168,10 +167,6 @@ public function testExcludeShares() {
return new \OC\Share20\Share($rootFolder, $userManager);
}));

$storage = $this->createMock(Storage::class);
$storage->method('getPermissions')->willReturn(1);
$this->loader->method('getInstance')->willReturn($storage);

$mounts = $this->provider->getMountsForUser($this->user, $this->loader);

$this->assertCount(2, $mounts);
Expand All @@ -196,40 +191,6 @@ public function testExcludeShares() {
$this->assertEquals(true, $mountedShare2->getAttributes()->getAttribute('permission', 'download'));
}

public function testShareFailedStorage() {
$rootFolder = $this->createMock('\OCP\Files\IRootFolder');
$userManager = $this->createMock('\OCP\IUserManager');

$attr2 = [["scope" => "permission", "key" => "download", "enabled" => true]];
$share = $this->makeMockShare(2, 100, 'user2', '/share2', 31, $attr2);

$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('user1'));

$requiredShareTypes = [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP];
$this->shareManager->expects($this->once())
->method('getAllSharedWith')
->with('user1', $requiredShareTypes, null)
->will($this->returnValue([$share]));
$this->shareManager->expects($this->never())
->method('getSharedWith');
$this->shareManager->expects($this->any())
->method('newShare')
->will($this->returnCallback(function () use ($rootFolder, $userManager) {
return new \OC\Share20\Share($rootFolder, $userManager);
}));

$storage = $this->createMock(Storage::class);
$storage->method('getPermissions')->willReturn(0);
$this->loader->method('getInstance')
->with($this->anything(), '\OCA\Files_Sharing\SharedStorage', $this->anything())
->willReturn($storage);

$mounts = $this->provider->getMountsForUser($this->user, $this->loader);
$this->assertSame([], $mounts);
}

public function mergeSharesDataProvider() {
// note: the user in the specs here is the shareOwner not recipient
// the recipient is always "user1"
Expand Down Expand Up @@ -412,10 +373,6 @@ public function testMergeShares($userShares, $groupShares, $expectedShares, $mov
->will($this->throwException(new \InvalidArgumentException()));
}

$storage = $this->createMock(Storage::class);
$storage->method('getPermissions')->willReturn(1);
$this->loader->method('getInstance')->willReturn($storage);

$mounts = $this->provider->getMountsForUser($this->user, $this->loader);

$this->assertCount(\count($expectedShares), $mounts);
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/41059
@@ -0,0 +1,6 @@
Bugfix: Revert https://github.com/owncloud/core/pull/41014 for performance

The https://github.com/owncloud/core/pull/41014 PR introduced performance
problems for large installation. We're reverting that change

https://github.com/owncloud/core/pull/41059

0 comments on commit 1781f0b

Please sign in to comment.