Skip to content

Commit 7a1b2c7

Browse files
committed
Revert "fix(Share20\Manager): Ensure node is still accessible when checking share"
This reverts commit c2ca99e.
1 parent d7ce5d4 commit 7a1b2c7

File tree

2 files changed

+4
-38
lines changed

2 files changed

+4
-38
lines changed

lib/private/Share20/Manager.php

-9
Original file line numberDiff line numberDiff line change
@@ -1464,15 +1464,6 @@ protected function checkShare(IShare $share): void {
14641464
$this->deleteShare($share);
14651465
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
14661466
}
1467-
1468-
try {
1469-
$share->getNode();
1470-
// Ignore share, file is still accessible
1471-
} catch (NotFoundException) {
1472-
// Access lost, but maybe only temporarily, so don't delete the share right away
1473-
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
1474-
}
1475-
14761467
if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'no') === 'yes') {
14771468
$uids = array_unique([$share->getShareOwner(),$share->getSharedBy()]);
14781469
foreach ($uids as $uid) {

tests/lib/Share20/ManagerTest.php

+4-29
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use OCP\Files\Mount\IMountPoint;
2626
use OCP\Files\Mount\IShareOwnerlessMount;
2727
use OCP\Files\Node;
28-
use OCP\Files\NotFoundException;
2928
use OCP\Files\Storage\IStorage;
3029
use OCP\HintException;
3130
use OCP\IAppConfig;
@@ -675,24 +674,6 @@ public function testGetShareById(): void {
675674
}
676675

677676

678-
public function testGetShareByIdNodeAccessible(): void {
679-
$share = $this->createMock(IShare::class);
680-
$share
681-
->expects($this->once())
682-
->method('getNode')
683-
->willThrowException(new NotFoundException());
684-
685-
$this->defaultProvider
686-
->expects($this->once())
687-
->method('getShareById')
688-
->with(42)
689-
->willReturn($share);
690-
691-
$this->expectException(ShareNotFound::class);
692-
$this->manager->getShareById('default:42');
693-
}
694-
695-
696677
public function testGetExpiredShareById(): void {
697678
$this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
698679

@@ -2901,10 +2882,9 @@ public function testCreateShareOfIncomingFederatedShare(): void {
29012882
}
29022883

29032884
public function testGetSharesBy(): void {
2904-
$node = $this->createMock(Folder::class);
2905-
29062885
$share = $this->manager->newShare();
2907-
$share->setNode($node);
2886+
2887+
$node = $this->createMock(Folder::class);
29082888

29092889
$this->defaultProvider->expects($this->once())
29102890
->method('getSharesBy')
@@ -2957,8 +2937,6 @@ public function testGetSharesByOwnerless(): void {
29572937
* deleted (as they are evaluated). but share 8 should still be there.
29582938
*/
29592939
public function testGetSharesByExpiredLinkShares(): void {
2960-
$node = $this->createMock(File::class);
2961-
29622940
$manager = $this->createManagerMock()
29632941
->setMethods(['deleteShare'])
29642942
->getMock();
@@ -2972,7 +2950,6 @@ public function testGetSharesByExpiredLinkShares(): void {
29722950
for ($i = 0; $i < 8; $i++) {
29732951
$share = $this->manager->newShare();
29742952
$share->setId($i);
2975-
$share->setNode($node);
29762953
$shares[] = $share;
29772954
}
29782955

@@ -2993,6 +2970,8 @@ public function testGetSharesByExpiredLinkShares(): void {
29932970
$shares2[] = clone $shares[$i];
29942971
}
29952972

2973+
$node = $this->createMock(File::class);
2974+
29962975
/*
29972976
* Simulate the getSharesBy call.
29982977
*/
@@ -3154,10 +3133,8 @@ public function testGetShareByTokenHideDisabledUser(): void {
31543133
$date = new \DateTime();
31553134
$date->setTime(0, 0, 0);
31563135
$date->add(new \DateInterval('P2D'));
3157-
$node = $this->createMock(File::class);
31583136
$share = $this->manager->newShare();
31593137
$share->setExpirationDate($date);
3160-
$share->setNode($node);
31613138
$share->setShareOwner('owner');
31623139
$share->setSharedBy('sharedBy');
31633140

@@ -3235,10 +3212,8 @@ public function testGetShareByTokenNotExpired(): void {
32353212
$date = new \DateTime();
32363213
$date->setTime(0, 0, 0);
32373214
$date->add(new \DateInterval('P2D'));
3238-
$node = $this->createMock(Folder::class);
32393215
$share = $this->manager->newShare();
32403216
$share->setExpirationDate($date);
3241-
$share->setNode($node);
32423217

32433218
$this->defaultProvider->expects($this->once())
32443219
->method('getShareByToken')

0 commit comments

Comments
 (0)