diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index d0bde46e96d..d9bfa6e1127 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -7,7 +7,6 @@ */ namespace OCA\DAV\Connector\Sabre; -use OC\Files\Mount\MoveableMount; use OC\Files\Utils\PathHelper; use OC\Files\View; use OCA\DAV\AppInfo\Application; @@ -22,6 +21,7 @@ use OCP\Files\Folder; use OCP\Files\ForbiddenException; use OCP\Files\InvalidPathException; use OCP\Files\Mount\IMountManager; +use OCP\Files\Mount\IMovableMount; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\Files\StorageNotAvailableException; @@ -410,7 +410,7 @@ class Directory extends Node implements $isMovableMount = false; $sourceMount = Server::get(IMountManager::class)->find($this->fileView->getAbsolutePath($sourcePath)); $internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath)); - if ($sourceMount instanceof MoveableMount && $internalPath === '') { + if ($sourceMount instanceof IMovableMount && $internalPath === '') { $isMovableMount = true; } diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php index cffddb10766..68b6c82adef 100644 --- a/apps/dav/lib/Connector/Sabre/Node.php +++ b/apps/dav/lib/Connector/Sabre/Node.php @@ -9,7 +9,6 @@ declare(strict_types=1); */ namespace OCA\DAV\Connector\Sabre; -use OC\Files\Mount\MoveableMount; use OC\Files\Node\File; use OC\Files\Node\Folder; use OC\Files\View; @@ -19,6 +18,7 @@ use OCP\Files\DavUtil; use OCP\Files\FileInfo; use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; +use OCP\Files\Mount\IMovableMount; use OCP\Files\NotFoundException; use OCP\Files\Storage\ISharedStorage; use OCP\Files\StorageNotAvailableException; @@ -259,7 +259,7 @@ abstract class Node implements INode { * Eventually we need to do this properly */ $mountpoint = $this->info->getMountPoint(); - if (!($mountpoint instanceof MoveableMount)) { + if (!($mountpoint instanceof IMovableMount)) { /** * @psalm-suppress UnnecessaryVarAnnotation Rector doesn't trust the return type annotation * @var string $mountpointpath diff --git a/apps/files_external/lib/Lib/PersonalMount.php b/apps/files_external/lib/Lib/PersonalMount.php index d9dbddd1449..148825ffdaf 100644 --- a/apps/files_external/lib/Lib/PersonalMount.php +++ b/apps/files_external/lib/Lib/PersonalMount.php @@ -7,16 +7,17 @@ */ namespace OCA\Files_External\Lib; -use OC\Files\Mount\MoveableMount; use OCA\Files_External\Config\ExternalMountPoint; use OCA\Files_External\Service\UserStoragesService; +use OCP\Files\Mount\IMovableMount; use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorageFactory; +use Override; /** * Person mount points can be moved by the user */ -class PersonalMount extends ExternalMountPoint implements MoveableMount { +class PersonalMount extends ExternalMountPoint implements IMovableMount { /** * @param UserStoragesService $storagesService * @param int $storageId @@ -42,13 +43,8 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount { parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId); } - /** - * Move the mount point to $target - * - * @param string $target the target mount point - * @return bool - */ - public function moveMount($target) { + #[Override] + public function moveMount(string $target): bool { $storage = $this->storagesService->getStorage($this->numericExternalStorageId); // remove "/$user/files" prefix $targetParts = explode('/', trim($target, '/'), 3); @@ -58,12 +54,8 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount { return true; } - /** - * Remove the mount points - * - * @return bool - */ - public function removeMount() { + #[Override] + public function removeMount(): bool { $this->storagesService->removeStorage($this->numericExternalStorageId); return true; } diff --git a/apps/files_sharing/lib/External/Mount.php b/apps/files_sharing/lib/External/Mount.php index 49ca047ffb1..a83a0a25a2a 100644 --- a/apps/files_sharing/lib/External/Mount.php +++ b/apps/files_sharing/lib/External/Mount.php @@ -8,13 +8,13 @@ namespace OCA\Files_Sharing\External; use OC\Files\Mount\MountPoint; -use OC\Files\Mount\MoveableMount; use OC\Files\Storage\Storage; use OC\Files\Storage\StorageFactory; use OCA\Files_Sharing\ISharedMountPoint; +use OCP\Files\Mount\IMovableMount; use Override; -class Mount extends MountPoint implements MoveableMount, ISharedMountPoint { +class Mount extends MountPoint implements IMovableMount, ISharedMountPoint { public function __construct( string|Storage $storage, string $mountpoint, @@ -25,21 +25,15 @@ class Mount extends MountPoint implements MoveableMount, ISharedMountPoint { parent::__construct($storage, $mountpoint, $options, $loader, null, null, MountProvider::class); } - /** - * Move the mount point to $target - * - * @param string $target the target mount point - */ - public function moveMount($target): bool { + #[Override] + public function moveMount(string $target): bool { $result = $this->manager->setMountPoint($this->mountPoint, $target); $this->setMountPoint($target); return $result; } - /** - * Remove the mount points - */ + #[Override] public function removeMount(): bool { return $this->manager->removeShare($this->mountPoint); } diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index 9dc3faa3628..0d6fe7e83e0 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -10,22 +10,25 @@ namespace OCA\Files_Sharing; use OC\Files\Filesystem; use OC\Files\Mount\MountPoint; -use OC\Files\Mount\MoveableMount; use OCA\Files_Sharing\Exceptions\BrokenPath; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Events\InvalidateMountCacheEvent; +use OCP\Files\Mount\IMovableMount; use OCP\Files\Storage\IStorageFactory; use OCP\IDBConnection; use OCP\IUser; use OCP\Server; use OCP\Share\IShare; +use Override; use Psr\Log\LoggerInterface; /** * Shared mount points can be moved by the user */ -class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint { - /** @var ?SharedStorage $storage */ +class SharedMount extends MountPoint implements IMovableMount, ISharedMountPoint { + /** + * @var ?SharedStorage $storage + */ protected $storage = null; /** @var IShare */ @@ -74,7 +77,7 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint * @return string e.g. turns '/admin/files/test.txt' into '/test.txt' * @throws BrokenPath */ - protected function stripUserFilesPath($path) { + protected function stripUserFilesPath(string $path): string { $trimmed = ltrim($path, '/'); $split = explode('/', $trimmed); @@ -91,13 +94,8 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint return '/' . $relPath; } - /** - * Move the mount point to $target - * - * @param string $target the target mount point - * @return bool - */ - public function moveMount($target) { + #[Override] + public function moveMount(string $target): bool { $relTargetPath = $this->stripUserFilesPath($target); $share = $this->storage->getShare(); @@ -120,12 +118,8 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint return $result; } - /** - * Remove the mount points - * - * @return bool - */ - public function removeMount() { + #[Override] + public function removeMount(): bool { $mountManager = Filesystem::getMountManager(); /** @var SharedStorage $storage */ $storage = $this->getStorage(); @@ -181,7 +175,8 @@ class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint } } - public function getMountType() { + #[Override] + public function getMountType(): string { return 'shared'; } diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php index c200db7a83d..5431d3bfa3d 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -10,7 +10,6 @@ namespace OCA\Files_Versions\Listener; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use OC\DB\Exceptions\DbalException; use OC\Files\Filesystem; -use OC\Files\Mount\MoveableMount; use OC\Files\Node\NonExistingFile; use OC\Files\Node\NonExistingFolder; use OC\Files\View; @@ -36,6 +35,7 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IMimeTypeLoader; use OCP\Files\IRootFolder; +use OCP\Files\Mount\IMovableMount; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\IUserSession; @@ -396,7 +396,7 @@ class FileEventsListener implements IEventListener { $manager = Filesystem::getMountManager(); $mount = $manager->find($absOldPath); $internalPath = $mount->getInternalPath($absOldPath); - if ($internalPath === '' && $mount instanceof MoveableMount) { + if ($internalPath === '' && $mount instanceof IMovableMount) { return; } diff --git a/core/BackgroundJobs/GenerateMetadataJob.php b/core/BackgroundJobs/GenerateMetadataJob.php index 0fc116936c9..8cf4a65ad2b 100644 --- a/core/BackgroundJobs/GenerateMetadataJob.php +++ b/core/BackgroundJobs/GenerateMetadataJob.php @@ -8,12 +8,12 @@ declare(strict_types=1); namespace OC\Core\BackgroundJobs; -use OC\Files\Mount\MoveableMount; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\TimedJob; use OCP\Files\Folder; use OCP\Files\IRootFolder; +use OCP\Files\Mount\IMovableMount; use OCP\FilesMetadata\Exceptions\FilesMetadataNotFoundException; use OCP\FilesMetadata\IFilesMetadataManager; use OCP\IAppConfig; @@ -84,7 +84,7 @@ class GenerateMetadataJob extends TimedJob { private function scanFolder(Folder $folder): void { // Do not scan share and other moveable mounts. - if ($folder->getMountPoint() instanceof MoveableMount) { + if ($folder->getMountPoint() instanceof IMovableMount) { return; } diff --git a/lib/composer/composer/LICENSE b/lib/composer/composer/LICENSE index f27399a042d..62ecfd8d004 100644 --- a/lib/composer/composer/LICENSE +++ b/lib/composer/composer/LICENSE @@ -1,4 +1,3 @@ - Copyright (c) Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 35992e16837..4b14a9fa10e 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1755,7 +1755,6 @@ return array( 'OC\\Files\\Mount\\LocalHomeMountProvider' => $baseDir . '/lib/private/Files/Mount/LocalHomeMountProvider.php', 'OC\\Files\\Mount\\Manager' => $baseDir . '/lib/private/Files/Mount/Manager.php', 'OC\\Files\\Mount\\MountPoint' => $baseDir . '/lib/private/Files/Mount/MountPoint.php', - 'OC\\Files\\Mount\\MoveableMount' => $baseDir . '/lib/private/Files/Mount/MoveableMount.php', 'OC\\Files\\Mount\\ObjectHomeMountProvider' => $baseDir . '/lib/private/Files/Mount/ObjectHomeMountProvider.php', 'OC\\Files\\Mount\\RootMountProvider' => $baseDir . '/lib/private/Files/Mount/RootMountProvider.php', 'OC\\Files\\Node\\File' => $baseDir . '/lib/private/Files/Node/File.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 79c4de8f327..66567dca2f6 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1796,7 +1796,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Files\\Mount\\LocalHomeMountProvider' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/LocalHomeMountProvider.php', 'OC\\Files\\Mount\\Manager' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/Manager.php', 'OC\\Files\\Mount\\MountPoint' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/MountPoint.php', - 'OC\\Files\\Mount\\MoveableMount' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/MoveableMount.php', 'OC\\Files\\Mount\\ObjectHomeMountProvider' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/ObjectHomeMountProvider.php', 'OC\\Files\\Mount\\RootMountProvider' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/RootMountProvider.php', 'OC\\Files\\Node\\File' => __DIR__ . '/../../..' . '/lib/private/Files/Node/File.php', diff --git a/lib/private/Files/Mount/MoveableMount.php b/lib/private/Files/Mount/MoveableMount.php deleted file mode 100644 index da1b50d2ee9..00000000000 --- a/lib/private/Files/Mount/MoveableMount.php +++ /dev/null @@ -1,32 +0,0 @@ -isCreatable() || ( $parent->getInternalPath() === '' - && ($parent->getMountPoint() instanceof MoveableMount) + && ($parent->getMountPoint() instanceof IMovableMount) ) ) ) { diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 623c9d66d6e..da3900bff4a 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -11,7 +11,6 @@ use Icewind\Streams\CallbackWrapper; use OC\Files\Cache\CacheEntry; use OC\Files\Cache\Scanner; use OC\Files\Mount\MountPoint; -use OC\Files\Mount\MoveableMount; use OC\Files\Storage\Storage; use OC\Files\Storage\Wrapper\Quota; use OC\Files\Utils\PathHelper; @@ -35,6 +34,7 @@ use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountPoint; +use OCP\Files\Mount\IMovableMount; use OCP\Files\NotFoundException; use OCP\Files\ReservedWordException; use OCP\Files\Storage\IStorage; @@ -242,7 +242,7 @@ class View { * @param string $path relative to data/ */ protected function removeMount($mount, $path): bool { - if ($mount instanceof MoveableMount) { + if ($mount instanceof IMovableMount) { // cut of /user/files to get the relative path to data/user/files $pathParts = explode('/', $path, 4); $relPath = '/' . $pathParts[3]; @@ -501,7 +501,7 @@ class View { $absolutePath = $this->getAbsolutePath($path); $mount = Filesystem::getMountManager()->find($absolutePath); if ($mount->getInternalPath($absolutePath) === '') { - return $mount instanceof MoveableMount; + return $mount instanceof IMovableMount; } return $this->basicOperation('isDeletable', $path); } @@ -810,7 +810,7 @@ class View { $movedMounts[] = $mount1; $this->validateMountMove($movedMounts, $sourceParentMount, $mount2, !$this->targetIsNotShared($targetUser, $absolutePath2)); /** - * @var MountPoint|MoveableMount $mount1 + * @var MountPoint|IMovableMount $mount1 */ $sourceMountPoint = $mount1->getMountPoint(); $result = $mount1->moveMount($absolutePath2); @@ -900,7 +900,7 @@ class View { $sourcePath = $mount->getMountPoint(); } - if (!$mount instanceof MoveableMount) { + if (!$mount instanceof IMovableMount) { throw new ForbiddenException($l->t('Storage %s cannot be moved', [$sourcePath]), false); } @@ -1452,7 +1452,7 @@ class View { return false; } - if ($mount instanceof MoveableMount && $internalPath === '') { + if ($mount instanceof IMovableMount && $internalPath === '') { $data['permissions'] |= Constants::PERMISSION_DELETE; } if ($internalPath === '' && $data['name']) { @@ -1650,7 +1650,7 @@ class View { $permissions = $rootEntry['permissions']; // do not allow renaming/deleting the mount point if they are not shared files/folders // for shared files/folders we use the permissions given by the owner - if ($mount instanceof MoveableMount) { + if ($mount instanceof IMovableMount) { $rootEntry['permissions'] = $permissions | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE; } else { $rootEntry['permissions'] = $permissions & (Constants::PERMISSION_ALL - (Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index db5fcf5ae94..ffcb91f181b 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -10,7 +10,6 @@ namespace OC\Share20; use ArrayIterator; use OC\Core\AppInfo\ConfigLexicon; use OC\Files\Filesystem; -use OC\Files\Mount\MoveableMount; use OC\KnownUser\KnownUserService; use OC\Share\Constants as ShareConstants; use OC\Share20\Exception\ProviderException; @@ -26,6 +25,7 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; +use OCP\Files\Mount\IMovableMount; use OCP\Files\Mount\IShareOwnerlessMount; use OCP\Files\Node; use OCP\Files\NotFoundException; @@ -241,7 +241,7 @@ class Manager implements IManager { $permissions = 0; $nodesForUser = $userFolder->getById($share->getNodeId()); foreach ($nodesForUser as $node) { - if ($node->getInternalPath() === '' && !$node->getMountPoint() instanceof MoveableMount) { + if ($node->getInternalPath() === '' && !$node->getMountPoint() instanceof IMovableMount) { // for the root of non-movable mount, the permissions we see if limited by the mount itself, // so we instead use the "raw" permissions from the storage $permissions |= $node->getStorage()->getPermissions(''); diff --git a/lib/public/Files/DavUtil.php b/lib/public/Files/DavUtil.php index 342935fd6d9..50c005f0d58 100644 --- a/lib/public/Files/DavUtil.php +++ b/lib/public/Files/DavUtil.php @@ -7,7 +7,6 @@ namespace OCP\Files; -use OC\Files\Mount\MoveableMount; use OCP\Constants; use OCP\Files\Mount\IMovableMount; @@ -83,7 +82,7 @@ class DavUtil { public static function canRename(FileInfo $info, FileInfo $parent): bool { // the root of a movable mountpoint can be renamed regardless of the file permissions - if ($info->getMountPoint() instanceof MoveableMount && $info->getInternalPath() === '') { + if ($info->getMountPoint() instanceof IMovableMount && $info->getInternalPath() === '') { return true; } diff --git a/lib/public/Files/Mount/IMovableMount.php b/lib/public/Files/Mount/IMovableMount.php index dc4df7618c0..e9026c2446f 100644 --- a/lib/public/Files/Mount/IMovableMount.php +++ b/lib/public/Files/Mount/IMovableMount.php @@ -20,7 +20,7 @@ interface IMovableMount { * @return bool * @since 28.0.0 */ - public function moveMount($target); + public function moveMount(string $target); /** * Remove the mount points diff --git a/tests/lib/TestMoveableMountPoint.php b/tests/lib/TestMoveableMountPoint.php index 5906a90ee18..21565a357cd 100644 --- a/tests/lib/TestMoveableMountPoint.php +++ b/tests/lib/TestMoveableMountPoint.php @@ -8,30 +8,22 @@ namespace Test; -use OC\Files\Mount; use OC\Files\Mount\MountPoint; -use OC\Files\Mount\MoveableMount; +use OCP\Files\Mount\IMovableMount; +use Override; /** * Test moveable mount for mocking */ -class TestMoveableMountPoint extends MountPoint implements MoveableMount { - /** - * Move the mount point to $target - * - * @param string $target the target mount point - * @return bool - */ - public function moveMount($target) { +class TestMoveableMountPoint extends MountPoint implements IMovableMount { + #[Override] + public function moveMount(string $target): bool { $this->setMountPoint($target); + return true; } - /** - * Remove the mount points - * - * @return mixed - * @return bool - */ - public function removeMount() { + #[Override] + public function removeMount(): bool { + return false; } }