]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix moving movablemount over webdav
authorRobin Appelman <icewind@owncloud.com>
Tue, 17 Jun 2014 12:10:11 +0000 (14:10 +0200)
committerRobin Appelman <icewind@owncloud.com>
Tue, 17 Jun 2014 12:10:11 +0000 (14:10 +0200)
apps/files/appinfo/remote.php
apps/files_encryption/tests/webdav.php
apps/files_sharing/publicwebdav.php
lib/private/connector/sabre/objecttree.php
tests/lib/connector/sabre/objecttree.php

index 92c761838760db9e1b820346e0939c2d6f8650c4..dd5c470431a556498903c3f43241eb6d57fcb335 100644 (file)
@@ -49,8 +49,9 @@ $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree) {
        $rootInfo = $view->getFileInfo('');
 
        // Create ownCloud Dir
+       $mountManager = \OC\Files\Filesystem::getMountManager();
        $rootDir = new OC_Connector_Sabre_Directory($view, $rootInfo);
-       $objectTree->init($rootDir, $view);
+       $objectTree->init($rootDir, $view, $mountManager);
 
        $server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view));
        $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view));
index 84db54ff30b208a9e1a7cbb00505c0858cc7f91c..73bc9ce08dea9d0ca7d7647cb5b3fc87f9fac2d6 100755 (executable)
@@ -235,7 +235,8 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
                $view = new \OC\Files\View($root);
                $publicDir = new OC_Connector_Sabre_Directory($view, $view->getFileInfo(''));
                $objectTree = new \OC\Connector\Sabre\ObjectTree();
-               $objectTree->init($publicDir, $view);
+               $mountManager = \OC\Files\Filesystem::getMountManager();
+               $objectTree->init($publicDir, $view, $mountManager);
 
                // Fire up server
                $server = new \Sabre\DAV\Server($publicDir);
index 4c0eb1537cd63089116359eb986f5ba03b4870db..684edd976705b0165d363528fd8c7aa87be4e20b 100644 (file)
@@ -64,7 +64,8 @@ $server->subscribeEvent('beforeMethod', function () use ($server, $objectTree, $
        } else {
                $root = new OC_Connector_Sabre_File($view, $rootInfo);
        }
-       $objectTree->init($root, $view);
+       $mountManager = \OC\Files\Filesystem::getMountManager();
+       $objectTree->init($root, $view, $mountManager);
 
        $server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin($view));
        $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view));
index 2cadb5af52007016baad94919cb4d84eeeeb1f07..f2578e3c097ac5d55c261243a7fbd26e619a4eeb 100644 (file)
@@ -10,6 +10,7 @@ namespace OC\Connector\Sabre;
 
 use OC\Files\FileInfo;
 use OC\Files\Filesystem;
+use OC\Files\Mount\MoveableMount;
 
 class ObjectTree extends \Sabre\DAV\ObjectTree {
 
@@ -18,6 +19,11 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
         */
        protected $fileView;
 
+       /**
+        * @var \OC\Files\Mount\Manager
+        */
+       protected $mountManager;
+
        /**
         * Creates the object
         *
@@ -29,10 +35,12 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
        /**
         * @param \Sabre\DAV\ICollection $rootNode
         * @param \OC\Files\View $view
+        * @param \OC\Files\Mount\Manager $mountManager
         */
-       public function init(\Sabre\DAV\ICollection $rootNode, \OC\Files\View $view) {
+       public function init(\Sabre\DAV\ICollection $rootNode, \OC\Files\View $view, \OC\Files\Mount\Manager $mountManager) {
                $this->rootNode = $rootNode;
                $this->fileView = $view;
+               $this->mountManager = $mountManager;
        }
 
        /**
@@ -115,14 +123,15 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
                list($sourceDir,) = \Sabre\DAV\URLUtil::splitPath($sourcePath);
                list($destinationDir,) = \Sabre\DAV\URLUtil::splitPath($destinationPath);
 
-               $isShareMountPoint = false;
-               list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath( '/' . \OCP\User::getUser() . '/files/' . $sourcePath);
-               if ($storage instanceof \OCA\Files_Sharing\ISharedStorage && !$internalPath) {
-                       $isShareMountPoint = true;
+               $isMovableMount = false;
+               $sourceMount = $this->mountManager->find($this->fileView->getAbsolutePath($sourcePath));
+               $internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath));
+               if ($sourceMount instanceof MoveableMount && $internalPath === '') {
+                       $isMovableMount = true;
                }
 
                // check update privileges
-               if (!$this->fileView->isUpdatable($sourcePath) && !$isShareMountPoint) {
+               if (!$this->fileView->isUpdatable($sourcePath) && !$isMovableMount) {
                        throw new \Sabre\DAV\Exception\Forbidden();
                }
                if ($sourceDir !== $destinationDir) {
@@ -132,7 +141,7 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
                        if (!$this->fileView->isUpdatable($destinationDir)) {
                                throw new \Sabre\DAV\Exception\Forbidden();
                        }
-                       if (!$this->fileView->isDeletable($sourcePath)) {
+                       if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) {
                                throw new \Sabre\DAV\Exception\Forbidden();
                        }
                }
index 0075b7832b8e17316a2ce31d135acf45a1591172..a88e23bbe2ff24132f881955ef5972677f94f4af 100644 (file)
@@ -110,7 +110,8 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
                        ->will($this->returnValue(false));
 
                /** @var $objectTree \OC\Connector\Sabre\ObjectTree */
-               $objectTree->init($rootDir, $view);
+               $mountManager = \OC\Files\Filesystem::getMountManager();
+               $objectTree->init($rootDir, $view, $mountManager);
                $objectTree->move($source, $dest);
        }