X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Revert "Don't mount shares with failed underlying storages"
This reverts commit 692c9be.
and 635267e
  • Loading branch information
jvillafanez committed Oct 30, 2023
commit f635066c581a108f2a6cbc19c8efff7b31a671c6
9 changes: 1 addition & 8 deletions apps/files_sharing/lib/MountProvider.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
X Tutup