From cb1b366baf75da4c578bc534884eefa7f6b4b3d2 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 2 Aug 2024 14:30:52 +0200 Subject: [PATCH 1/2] fix(dav): Ensure share properties are also set on public remote endpoint Signed-off-by: Ferdinand Thiessen --- apps/dav/appinfo/v2/publicremote.php | 7 ++++ .../composer/composer/autoload_classmap.php | 1 + .../dav/composer/composer/autoload_static.php | 1 + apps/dav/lib/Connector/Sabre/FilesPlugin.php | 7 +--- apps/dav/lib/Connector/Sabre/Node.php | 34 ++++++++--------- apps/dav/lib/Storage/PublicShareWrapper.php | 38 +++++++++++++++++++ .../dav_features/dav-v2-public.feature | 22 +++++++++++ .../integration/features/bootstrap/WebDav.php | 27 ++++++++++++- build/integration/run-docker.sh | 6 +-- 9 files changed, 115 insertions(+), 28 deletions(-) create mode 100644 apps/dav/lib/Storage/PublicShareWrapper.php create mode 100644 build/integration/dav_features/dav-v2-public.feature diff --git a/apps/dav/appinfo/v2/publicremote.php b/apps/dav/appinfo/v2/publicremote.php index 44cf4214505da..53e85d556eb9f 100644 --- a/apps/dav/appinfo/v2/publicremote.php +++ b/apps/dav/appinfo/v2/publicremote.php @@ -10,6 +10,7 @@ use OC\Files\Storage\Wrapper\PermissionsMask; use OC\Files\View; use OCA\DAV\Storage\PublicOwnerWrapper; +use OCA\DAV\Storage\PublicShareWrapper; use OCA\FederatedFileSharing\FederatedShareProvider; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Mount\IMountManager; @@ -98,6 +99,12 @@ return new PublicOwnerWrapper(['storage' => $storage, 'owner' => $share->getShareOwner()]); }); + // Ensure that also private shares have the `getShare` method + /** @psalm-suppress MissingClosureParamType */ + Filesystem::addStorageWrapper('getShare', function ($mountPoint, $storage) use ($share) { + return new PublicShareWrapper(['storage' => $storage, 'share' => $share]); + }, 0); + /** @psalm-suppress InternalMethod */ Filesystem::logWarningWhenAddingStorageWrapper($previousLog); diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php index 5081cc0ae97df..adbf0a23d3664 100644 --- a/apps/dav/composer/composer/autoload_classmap.php +++ b/apps/dav/composer/composer/autoload_classmap.php @@ -350,6 +350,7 @@ 'OCA\\DAV\\SetupChecks\\NeedsSystemAddressBookSync' => $baseDir . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\DAV\\SetupChecks\\WebdavEndpoint' => $baseDir . '/../lib/SetupChecks/WebdavEndpoint.php', 'OCA\\DAV\\Storage\\PublicOwnerWrapper' => $baseDir . '/../lib/Storage/PublicOwnerWrapper.php', + 'OCA\\DAV\\Storage\\PublicShareWrapper' => $baseDir . '/../lib/Storage/PublicShareWrapper.php', 'OCA\\DAV\\SystemTag\\SystemTagList' => $baseDir . '/../lib/SystemTag/SystemTagList.php', 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => $baseDir . '/../lib/SystemTag/SystemTagMappingNode.php', 'OCA\\DAV\\SystemTag\\SystemTagNode' => $baseDir . '/../lib/SystemTag/SystemTagNode.php', diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php index 79bddfe8717b5..975af1af81fcf 100644 --- a/apps/dav/composer/composer/autoload_static.php +++ b/apps/dav/composer/composer/autoload_static.php @@ -365,6 +365,7 @@ class ComposerStaticInitDAV 'OCA\\DAV\\SetupChecks\\NeedsSystemAddressBookSync' => __DIR__ . '/..' . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\DAV\\SetupChecks\\WebdavEndpoint' => __DIR__ . '/..' . '/../lib/SetupChecks/WebdavEndpoint.php', 'OCA\\DAV\\Storage\\PublicOwnerWrapper' => __DIR__ . '/..' . '/../lib/Storage/PublicOwnerWrapper.php', + 'OCA\\DAV\\Storage\\PublicShareWrapper' => __DIR__ . '/..' . '/../lib/Storage/PublicShareWrapper.php', 'OCA\\DAV\\SystemTag\\SystemTagList' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagList.php', 'OCA\\DAV\\SystemTag\\SystemTagMappingNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagMappingNode.php', 'OCA\\DAV\\SystemTag\\SystemTagNode' => __DIR__ . '/..' . '/../lib/SystemTag/SystemTagNode.php', diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 3b96f67a82b77..132440049936e 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -345,13 +345,10 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) return $node->getNode()->getInternalPath() === '' ? 'true' : 'false'; }); - $propFind->handle(self::SHARE_NOTE, function () use ($node, $httpRequest): ?string { + $propFind->handle(self::SHARE_NOTE, function () use ($node, $httpRequest): string { $user = $this->userSession->getUser(); - if ($user === null) { - return null; - } return $node->getNoteFromShare( - $user->getUID() + $user?->getUID() ); }); diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 379574b30d695..075ea2dd65bfb 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -15,6 +15,7 @@ use OCP\Files\DavUtil; use OCP\Files\FileInfo; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\Files\StorageNotAvailableException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; @@ -298,15 +299,14 @@ public function getSharePermissions($user) { * @return array */ public function getShareAttributes(): array { - $attributes = []; - try { - $storage = $this->info->getStorage(); - } catch (StorageNotAvailableException $e) { - $storage = null; + $storage = $this->node->getStorage(); + } catch (NotFoundException $e) { + return []; } - if ($storage && $storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { + $attributes = []; + if (method_exists($storage, 'getShare')) { /** @var \OCA\Files_Sharing\SharedStorage $storage */ $attributes = $storage->getShare()->getAttributes(); if ($attributes === null) { @@ -319,29 +319,25 @@ public function getShareAttributes(): array { return $attributes; } - /** - * @param string $user - * @return string - */ - public function getNoteFromShare($user) { - if ($user === null) { + public function getNoteFromShare(?string $user): string { + try { + $storage = $this->node->getStorage(); + } catch (NotFoundException) { return ''; } - // Retrieve note from the share object already loaded into - // memory, to avoid additional database queries. - $storage = $this->getNode()->getStorage(); - if (!$storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { + if (!method_exists($storage, 'getShare')) { return ''; } /** @var \OCA\Files_Sharing\SharedStorage $storage */ $share = $storage->getShare(); $note = $share->getNote(); - if ($share->getShareOwner() !== $user) { - return $note; + if ($user === $share->getShareOwner()) { + // Note is only for recipient not the owner + return ''; } - return ''; + return $note; } /** diff --git a/apps/dav/lib/Storage/PublicShareWrapper.php b/apps/dav/lib/Storage/PublicShareWrapper.php new file mode 100644 index 0000000000000..fb24abda9d042 --- /dev/null +++ b/apps/dav/lib/Storage/PublicShareWrapper.php @@ -0,0 +1,38 @@ + $storage, 'share' => $share] + * + * $storage: The storage the permissions mask should be applied on + * $share: The share to use in case no share is found + */ + public function __construct($arguments) { + parent::__construct($arguments); + $this->share = $arguments['share']; + } + + public function getShare(): IShare { + $storage = parent::getWrapperStorage(); + if (method_exists($storage, 'getShare')) { + /** @var \OCA\Files_Sharing\SharedStorage $storage */ + return $storage->getShare(); + } + + return $this->share; + } +} diff --git a/build/integration/dav_features/dav-v2-public.feature b/build/integration/dav_features/dav-v2-public.feature new file mode 100644 index 0000000000000..773fc2c1d73eb --- /dev/null +++ b/build/integration/dav_features/dav-v2-public.feature @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +Feature: dav-v2-public + Background: + Given using api version "1" + + Scenario: See note to recipient in public shares + Given using new dav path + And As an "admin" + And user "user0" exists + And user "user1" exists + And As an "user1" + And user "user1" created a folder "/testshare" + And as "user1" creating a share with + | path | testshare | + | shareType | 3 | + | permissions | 1 | + | note | Hello | + And As an "user0" + Given using new public dav path + When Requesting share note on dav endpoint + Then the single response should contain a property "{http://nextcloud.org/ns}note" with value "Hello" diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 852317f76a345..fff990fc14178 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -52,6 +52,14 @@ public function usingNewDavPath() { $this->usingOldDavPath = false; } + /** + * @Given /^using new public dav path$/ + */ + public function usingNewPublicDavPath() { + $this->davPath = "public.php/dav"; + $this->usingOldDavPath = false; + } + public function getDavFilesPath($user) { if ($this->usingOldDavPath === true) { return $this->davPath; @@ -75,7 +83,7 @@ public function makeDavRequest($user, $method, $path, $headers, $body = null, $t ]; if ($user === 'admin') { $options['auth'] = $this->adminUser; - } else { + } elseif ($user !== '') { $options['auth'] = [$user, $this->regularUser]; } return $client->request($method, $fullUrl, $options); @@ -941,6 +949,23 @@ public function connectingToDavEndpoint() { } } + /** + * @When Requesting share note on dav endpoint + */ + public function requestingShareNote() { + $propfind = ''; + if (count($this->lastShareData->data->element) > 0) { + $token = $this->lastShareData->data[0]->token; + } else { + $token = $this->lastShareData->data->token; + } + try { + $this->response = $this->makeDavRequest('', 'PROPFIND', $token, [], $propfind); + } catch (\GuzzleHttp\Exception\ClientException $e) { + $this->response = $e->getResponse(); + } + } + /** * @Then there are no duplicate headers */ diff --git a/build/integration/run-docker.sh b/build/integration/run-docker.sh index f49fd3ea65080..11563c9aa2140 100755 --- a/build/integration/run-docker.sh +++ b/build/integration/run-docker.sh @@ -201,7 +201,7 @@ cd "$(dirname $0)" # "--image XXX" option can be provided to set the Docker image to use to run # the integration tests (one of the "nextcloudci/phpX.Y:phpX.Y-Z" or # "ghcr.io/nextcloud/continuous-integration-integration-phpX.Y:latest" images). -NEXTCLOUD_LOCAL_IMAGE="ghcr.io/nextcloud/continuous-integration-integration-php8.0:latest" +NEXTCLOUD_LOCAL_IMAGE="ghcr.io/nextcloud/continuous-integration-integration-php8.1:latest" if [ "$1" = "--image" ]; then NEXTCLOUD_LOCAL_IMAGE=$2 @@ -227,9 +227,9 @@ fi # "--database-image XXX" option can be provided to set the Docker image to use # for the database container (ignored when using "sqlite"). if [ "$DATABASE" = "mysql" ]; then - DATABASE_IMAGE="mysql:5.7" + DATABASE_IMAGE="mysql:8.4" elif [ "$DATABASE" = "pgsql" ]; then - DATABASE_IMAGE="postgres:10" + DATABASE_IMAGE="postgres:15" fi if [ "$1" = "--database-image" ]; then DATABASE_IMAGE=$2 From 4bbcbc520620b59c19f058fa79e107ee1a8ce275 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 5 Aug 2024 17:51:45 +0200 Subject: [PATCH 2/2] feat: Make `ISharedStorage` public API and reuse where possible Signed-off-by: Ferdinand Thiessen --- apps/dav/lib/Connector/Sabre/FilesPlugin.php | 4 +-- apps/dav/lib/Connector/Sabre/Node.php | 32 +++++++++---------- apps/dav/lib/DAV/ViewOnlyPlugin.php | 5 +-- apps/dav/lib/Storage/PublicShareWrapper.php | 5 +-- .../tests/unit/Connector/Sabre/NodeTest.php | 14 +++++--- .../dav/tests/unit/DAV/ViewOnlyPluginTest.php | 5 +-- apps/files_sharing/lib/ISharedStorage.php | 3 ++ apps/files_sharing/lib/SharedStorage.php | 5 +-- .../lib/Versions/LegacyVersionsBackend.php | 7 ++-- build/integration/run-docker.sh | 2 +- lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + lib/public/Files/Storage/ISharedStorage.php | 26 +++++++++++++++ 13 files changed, 75 insertions(+), 35 deletions(-) create mode 100644 lib/public/Files/Storage/ISharedStorage.php diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index 132440049936e..bca0d15709f3c 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -345,14 +345,14 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) return $node->getNode()->getInternalPath() === '' ? 'true' : 'false'; }); - $propFind->handle(self::SHARE_NOTE, function () use ($node, $httpRequest): string { + $propFind->handle(self::SHARE_NOTE, function () use ($node): ?string { $user = $this->userSession->getUser(); return $node->getNoteFromShare( $user?->getUID() ); }); - $propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function () use ($node) { + $propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function () { return $this->config->getSystemValue('data-fingerprint', ''); }); $propFind->handle(self::CREATIONDATE_PROPERTYNAME, function () use ($node) { diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index 075ea2dd65bfb..973d5ca6f0ea9 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -16,6 +16,7 @@ use OCP\Files\FileInfo; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; +use OCP\Files\Storage\ISharedStorage; use OCP\Files\StorageNotAvailableException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; @@ -262,8 +263,8 @@ public function getSharePermissions($user) { $storage = null; } - if ($storage && $storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { - /** @var \OCA\Files_Sharing\SharedStorage $storage */ + if ($storage && $storage->instanceOfStorage(ISharedStorage::class)) { + /** @var ISharedStorage $storage */ $permissions = (int)$storage->getShare()->getPermissions(); } else { $permissions = $this->info->getPermissions(); @@ -306,8 +307,8 @@ public function getShareAttributes(): array { } $attributes = []; - if (method_exists($storage, 'getShare')) { - /** @var \OCA\Files_Sharing\SharedStorage $storage */ + if ($storage->instanceOfStorage(ISharedStorage::class)) { + /** @var ISharedStorage $storage */ $attributes = $storage->getShare()->getAttributes(); if ($attributes === null) { return []; @@ -319,25 +320,24 @@ public function getShareAttributes(): array { return $attributes; } - public function getNoteFromShare(?string $user): string { + public function getNoteFromShare(?string $user): ?string { try { $storage = $this->node->getStorage(); } catch (NotFoundException) { - return ''; + return null; } - if (!method_exists($storage, 'getShare')) { - return ''; + if ($storage->instanceOfStorage(ISharedStorage::class)) { + /** @var ISharedStorage $storage */ + $share = $storage->getShare(); + if ($user === $share->getShareOwner()) { + // Note is only for recipient not the owner + return null; + } + return $share->getNote(); } - /** @var \OCA\Files_Sharing\SharedStorage $storage */ - $share = $storage->getShare(); - $note = $share->getNote(); - if ($user === $share->getShareOwner()) { - // Note is only for recipient not the owner - return ''; - } - return $note; + return null; } /** diff --git a/apps/dav/lib/DAV/ViewOnlyPlugin.php b/apps/dav/lib/DAV/ViewOnlyPlugin.php index 80d0ddc8cf998..b6139638aa5e5 100644 --- a/apps/dav/lib/DAV/ViewOnlyPlugin.php +++ b/apps/dav/lib/DAV/ViewOnlyPlugin.php @@ -13,6 +13,7 @@ use OCA\Files_Versions\Sabre\VersionFile; use OCP\Files\Folder; use OCP\Files\NotFoundException; +use OCP\Files\Storage\ISharedStorage; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; @@ -81,11 +82,11 @@ public function checkViewOnly(RequestInterface $request): bool { $storage = $node->getStorage(); - if (!$storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { + if (!$storage->instanceOfStorage(ISharedStorage::class)) { return true; } // Extract extra permissions - /** @var \OCA\Files_Sharing\SharedStorage $storage */ + /** @var ISharedStorage $storage */ $share = $storage->getShare(); $attributes = $share->getAttributes(); diff --git a/apps/dav/lib/Storage/PublicShareWrapper.php b/apps/dav/lib/Storage/PublicShareWrapper.php index fb24abda9d042..058dbe2bcea75 100644 --- a/apps/dav/lib/Storage/PublicShareWrapper.php +++ b/apps/dav/lib/Storage/PublicShareWrapper.php @@ -9,9 +9,10 @@ namespace OCA\DAV\Storage; use OC\Files\Storage\Wrapper\Wrapper; +use OCP\Files\Storage\ISharedStorage; use OCP\Share\IShare; -class PublicShareWrapper extends Wrapper { +class PublicShareWrapper extends Wrapper implements ISharedStorage { private IShare $share; @@ -29,7 +30,7 @@ public function __construct($arguments) { public function getShare(): IShare { $storage = parent::getWrapperStorage(); if (method_exists($storage, 'getShare')) { - /** @var \OCA\Files_Sharing\SharedStorage $storage */ + /** @var ISharedStorage $storage */ return $storage->getShare(); } diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index 17550a2874f01..83f4139a2d9ef 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -10,6 +10,7 @@ use OC\Files\FileInfo; use OC\Files\Mount\MountPoint; +use OC\Files\Node\Folder; use OC\Files\View; use OC\Share20\ShareAttributes; use OCA\Files_Sharing\SharedMount; @@ -21,6 +22,7 @@ use OCP\ICache; use OCP\Share\IManager; use OCP\Share\IShare; +use PHPUnit\Framework\MockObject\MockObject; /** * Class NodeTest @@ -201,14 +203,16 @@ public function testShareAttributes(): void { $share->expects($this->once())->method('getAttributes')->willReturn($attributes); - $info = $this->getMockBuilder(FileInfo::class) + /** @var Folder&MockObject $info */ + $info = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() - ->setMethods(['getStorage', 'getType']) + ->onlyMethods(['getStorage', 'getType']) ->getMock(); $info->method('getStorage')->willReturn($storage); $info->method('getType')->willReturn(FileInfo::TYPE_FOLDER); + /** @var View&MockObject $view */ $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); @@ -225,14 +229,16 @@ public function testShareAttributesNonShare(): void { $shareManager = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock(); - $info = $this->getMockBuilder(FileInfo::class) + /** @var Folder&MockObject */ + $info = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() - ->setMethods(['getStorage', 'getType']) + ->onlyMethods(['getStorage', 'getType']) ->getMock(); $info->method('getStorage')->willReturn($storage); $info->method('getType')->willReturn(FileInfo::TYPE_FOLDER); + /** @var View&MockObject */ $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php b/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php index 63dd5b9145cae..eb15bfe0b5a19 100644 --- a/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php +++ b/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php @@ -15,6 +15,7 @@ use OCA\Files_Versions\Versions\IVersion; use OCP\Files\File; use OCP\Files\Folder; +use OCP\Files\Storage\ISharedStorage; use OCP\Files\Storage\IStorage; use OCP\IUser; use OCP\Share\IAttributes; @@ -65,7 +66,7 @@ public function testCanGetNonShared(): void { $storage = $this->createMock(IStorage::class); $file->method('getStorage')->willReturn($storage); - $storage->method('instanceOfStorage')->with(SharedStorage::class)->willReturn(false); + $storage->method('instanceOfStorage')->with(ISharedStorage::class)->willReturn(false); $this->assertTrue($this->plugin->checkViewOnly($this->request)); } @@ -140,7 +141,7 @@ public function testCanGet(bool $isVersion, ?bool $attrEnabled, bool $expectCanD $nodeInfo->expects($this->once()) ->method('getStorage') ->willReturn($storage); - $storage->method('instanceOfStorage')->with(SharedStorage::class)->willReturn(true); + $storage->method('instanceOfStorage')->with(ISharedStorage::class)->willReturn(true); $storage->method('getShare')->willReturn($share); $extAttr = $this->createMock(IAttributes::class); diff --git a/apps/files_sharing/lib/ISharedStorage.php b/apps/files_sharing/lib/ISharedStorage.php index 8a8e6bc10a944..dfd8b134db19f 100644 --- a/apps/files_sharing/lib/ISharedStorage.php +++ b/apps/files_sharing/lib/ISharedStorage.php @@ -8,5 +8,8 @@ use OCP\Files\Storage\IStorage; +/** + * @deprecated 30.0.0 use `\OCP\Files\Storage\ISharedStorage` instead + */ interface ISharedStorage extends IStorage { } diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index f8b318dcc5b91..386553a51edfd 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -18,15 +18,16 @@ use OC\Files\Storage\Wrapper\Wrapper; use OC\User\NoUserException; use OCA\Files_External\Config\ConfigAdapter; +use OCA\Files_Sharing\ISharedStorage as LegacyISharedStorage; use OCP\Constants; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Config\IUserMountCache; use OCP\Files\Folder; use OCP\Files\IHomeStorage; use OCP\Files\IRootFolder; -use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\Storage\IDisableEncryptionStorage; +use OCP\Files\Storage\ISharedStorage; use OCP\Files\Storage\IStorage; use OCP\Lock\ILockingProvider; use OCP\Share\IShare; @@ -35,7 +36,7 @@ /** * Convert target path to source path and pass the function call to the correct storage provider */ -class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage, IDisableEncryptionStorage { +class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISharedStorage, ISharedStorage, IDisableEncryptionStorage { /** @var \OCP\Share\IShare */ private $superShare; diff --git a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php index 1483d03bcc6c3..b5b948dda5bc1 100644 --- a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php +++ b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php @@ -12,8 +12,6 @@ use Exception; use OC\Files\View; use OCA\DAV\Connector\Sabre\Exception\Forbidden; -use OCA\Files_Sharing\ISharedStorage; -use OCA\Files_Sharing\SharedStorage; use OCA\Files_Versions\Db\VersionEntity; use OCA\Files_Versions\Db\VersionsMapper; use OCA\Files_Versions\Storage; @@ -24,6 +22,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; +use OCP\Files\Storage\ISharedStorage; use OCP\Files\Storage\IStorage; use OCP\IUser; use OCP\IUserManager; @@ -48,7 +47,7 @@ public function useBackendForStorage(IStorage $storage): bool { public function getVersionsForFile(IUser $user, FileInfo $file): array { $storage = $file->getStorage(); - if ($storage->instanceOfStorage(SharedStorage::class)) { + if ($storage->instanceOfStorage(ISharedStorage::class)) { $owner = $storage->getOwner(''); $user = $this->userManager->get($owner); @@ -192,7 +191,7 @@ public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): Fi // Shared files have their versions in the owners root folder so we need to obtain them from there if ($storage->instanceOfStorage(ISharedStorage::class) && $owner) { - /** @var SharedStorage $storage */ + /** @var ISharedStorage $storage */ $userFolder = $this->rootFolder->getUserFolder($owner->getUID()); $user = $owner; $ownerPathInStorage = $sourceFile->getInternalPath(); diff --git a/build/integration/run-docker.sh b/build/integration/run-docker.sh index 11563c9aa2140..e1ec797fcf04a 100755 --- a/build/integration/run-docker.sh +++ b/build/integration/run-docker.sh @@ -201,7 +201,7 @@ cd "$(dirname $0)" # "--image XXX" option can be provided to set the Docker image to use to run # the integration tests (one of the "nextcloudci/phpX.Y:phpX.Y-Z" or # "ghcr.io/nextcloud/continuous-integration-integration-phpX.Y:latest" images). -NEXTCLOUD_LOCAL_IMAGE="ghcr.io/nextcloud/continuous-integration-integration-php8.1:latest" +NEXTCLOUD_LOCAL_IMAGE="ghcr.io/nextcloud/continuous-integration-integration-php8.2:latest" if [ "$1" = "--image" ]; then NEXTCLOUD_LOCAL_IMAGE=$2 diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 8a6c6f8ccc2b4..7c44d95422349 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -432,6 +432,7 @@ 'OCP\\Files\\Storage\\ILockingStorage' => $baseDir . '/lib/public/Files/Storage/ILockingStorage.php', 'OCP\\Files\\Storage\\INotifyStorage' => $baseDir . '/lib/public/Files/Storage/INotifyStorage.php', 'OCP\\Files\\Storage\\IReliableEtagStorage' => $baseDir . '/lib/public/Files/Storage/IReliableEtagStorage.php', + 'OCP\\Files\\Storage\\ISharedStorage' => $baseDir . '/lib/public/Files/Storage/ISharedStorage.php', 'OCP\\Files\\Storage\\IStorage' => $baseDir . '/lib/public/Files/Storage/IStorage.php', 'OCP\\Files\\Storage\\IStorageFactory' => $baseDir . '/lib/public/Files/Storage/IStorageFactory.php', 'OCP\\Files\\Storage\\IWriteStreamStorage' => $baseDir . '/lib/public/Files/Storage/IWriteStreamStorage.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 3b758ff71fe93..63fa40d39bf78 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -465,6 +465,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Files\\Storage\\ILockingStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/ILockingStorage.php', 'OCP\\Files\\Storage\\INotifyStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/INotifyStorage.php', 'OCP\\Files\\Storage\\IReliableEtagStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IReliableEtagStorage.php', + 'OCP\\Files\\Storage\\ISharedStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/ISharedStorage.php', 'OCP\\Files\\Storage\\IStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IStorage.php', 'OCP\\Files\\Storage\\IStorageFactory' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IStorageFactory.php', 'OCP\\Files\\Storage\\IWriteStreamStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IWriteStreamStorage.php', diff --git a/lib/public/Files/Storage/ISharedStorage.php b/lib/public/Files/Storage/ISharedStorage.php new file mode 100644 index 0000000000000..836c4aefcdbe6 --- /dev/null +++ b/lib/public/Files/Storage/ISharedStorage.php @@ -0,0 +1,26 @@ +