diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-03-28 21:56:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-28 21:56:44 +0200 |
commit | 4821c00ea81797fcb5a99c31105ad42be598f113 (patch) | |
tree | 6b56762ce35894d849ffc139dfddb3c19e1fc97e /apps | |
parent | e26f138fc596492da88b8a0d57749f5703e1d100 (diff) | |
parent | ae3016959e6cbcadcd5169fa9e35a332abcc4495 (diff) | |
download | nextcloud-server-4821c00ea81797fcb5a99c31105ad42be598f113.tar.gz nextcloud-server-4821c00ea81797fcb5a99c31105ad42be598f113.zip |
Merge pull request #4004 from nextcloud/backport-27172
Remove SharedCache::getNumericStorageId to let CacheWrapper do it
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/tests/CacheTest.php | 27 |
3 files changed, 35 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index bc10ddbd94f..d7dcb426d85 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -51,6 +51,8 @@ class Cache extends CacheJail { private $ownerDisplayName; + private $numericId; + /** * @param \OCA\Files_Sharing\SharedStorage $storage * @param ICacheEntry $sourceRootInfo @@ -58,6 +60,7 @@ class Cache extends CacheJail { public function __construct($storage, ICacheEntry $sourceRootInfo) { $this->storage = $storage; $this->sourceRootInfo = $sourceRootInfo; + $this->numericId = $sourceRootInfo->getStorageId(); parent::__construct( null, $this->sourceRootInfo->getPath() diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index ddbc9b8a898..3293e095590 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -350,6 +350,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto return $this->superShare->getNodeType(); } + /** + * @param string $path + * @param null $storage + * @return Cache + */ public function getCache($path = '', $storage = null) { if ($this->cache) { return $this->cache; diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index ae0247a84e2..26ba5b21e46 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -30,6 +30,8 @@ namespace OCA\Files_Sharing\Tests; +use OCA\Files_Sharing\SharedStorage; + /** * Class CacheTest * @@ -525,4 +527,29 @@ class CacheTest extends TestCase { $this->assertEquals('', $sharedCache->getPathById($folderInfo->getId())); $this->assertEquals('bar/test.txt', $sharedCache->getPathById($fileInfo->getId())); } + + public function testNumericStorageId() { + self::loginHelper(self::TEST_FILES_SHARING_API_USER1); + \OC\Files\Filesystem::mkdir('foo'); + + $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1); + $node = $rootFolder->get('foo'); + $share = $this->shareManager->newShare(); + $share->setNode($node) + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedWith(self::TEST_FILES_SHARING_API_USER2) + ->setSharedBy(self::TEST_FILES_SHARING_API_USER1) + ->setPermissions(\OCP\Constants::PERMISSION_ALL); + $this->shareManager->createShare($share); + \OC_Util::tearDownFS(); + + list($sourceStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/foo'); + + self::loginHelper(self::TEST_FILES_SHARING_API_USER2); + $this->assertTrue(\OC\Files\Filesystem::file_exists('/foo')); + /** @var SharedStorage $sharedStorage */ + list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo'); + + $this->assertEquals($sourceStorage->getCache()->getNumericStorageId(), $sharedStorage->getCache()->getNumericStorageId()); + } } |