|
14 | 14 | use OC\Files\View; |
15 | 15 | use OCA\Files_Sharing\SharedStorage; |
16 | 16 | use OCP\Constants; |
| 17 | +use OCP\Files\Cache\IWatcher; |
17 | 18 | use OCP\Share\IShare; |
18 | 19 |
|
19 | 20 | /** |
@@ -567,4 +568,38 @@ public function testSearchShareJailedStorage(): void { |
567 | 568 | $results = $sharedStorage->getCache()->search('foo.txt'); |
568 | 569 | $this->assertCount(1, $results); |
569 | 570 | } |
| 571 | + |
| 572 | + public function testWatcherRootChange() { |
| 573 | + $sourceStorage = new Temporary(); |
| 574 | + $sourceStorage->mkdir('shared'); |
| 575 | + $sourceStorage->file_put_contents('shared/foo.txt', 'foo'); |
| 576 | + $sourceStorage->getScanner()->scan(''); |
| 577 | + $sourceStorage->getWatcher()->setPolicy(IWatcher::CHECK_ALWAYS); |
| 578 | + $this->registerMount(self::TEST_FILES_SHARING_API_USER1, $sourceStorage, '/' . self::TEST_FILES_SHARING_API_USER1 . '/files/foo'); |
| 579 | + |
| 580 | + self::loginHelper(self::TEST_FILES_SHARING_API_USER1); |
| 581 | + |
| 582 | + $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1); |
| 583 | + $node = $rootFolder->get('foo/shared'); |
| 584 | + $this->assertEquals(3, $node->getSize()); |
| 585 | + |
| 586 | + $share = $this->shareManager->newShare(); |
| 587 | + $share->setNode($node) |
| 588 | + ->setShareType(IShare::TYPE_USER) |
| 589 | + ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) |
| 590 | + ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) |
| 591 | + ->setPermissions(Constants::PERMISSION_ALL); |
| 592 | + $share = $this->shareManager->createShare($share); |
| 593 | + $share->setStatus(IShare::STATUS_ACCEPTED); |
| 594 | + $this->shareManager->updateShare($share); |
| 595 | + \OC_Util::tearDownFS(); |
| 596 | + |
| 597 | + self::loginHelper(self::TEST_FILES_SHARING_API_USER2); |
| 598 | + |
| 599 | + $view = Filesystem::getView(); |
| 600 | + |
| 601 | + $sourceStorage->rmdir('shared'); |
| 602 | + |
| 603 | + $this->assertFalse($view->getFileInfo('shared')); |
| 604 | + } |
570 | 605 | } |
0 commit comments