[Pkg-owncloud-commits] [owncloud] 180/223: Fix moving movablemount over webdav

David Prévot taffit at moszumanska.debian.org
Sun Jun 22 01:54:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 07fdeba50b47848c995d38408635020e08cecb19
Author: Robin Appelman <icewind at owncloud.com>
Date:   Tue Jun 17 14:10:11 2014 +0200

    Fix moving movablemount over webdav
---
 apps/files/appinfo/remote.php              |  3 ++-
 apps/files_encryption/tests/webdav.php     |  3 ++-
 apps/files_sharing/publicwebdav.php        |  3 ++-
 lib/private/connector/sabre/objecttree.php | 23 ++++++++++++++++-------
 tests/lib/connector/sabre/objecttree.php   |  3 ++-
 5 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php
index 92c7618..dd5c470 100644
--- a/apps/files/appinfo/remote.php
+++ b/apps/files/appinfo/remote.php
@@ -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));
diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php
index 84db54f..73bc9ce 100755
--- a/apps/files_encryption/tests/webdav.php
+++ b/apps/files_encryption/tests/webdav.php
@@ -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);
diff --git a/apps/files_sharing/publicwebdav.php b/apps/files_sharing/publicwebdav.php
index 4c0eb15..684edd9 100644
--- a/apps/files_sharing/publicwebdav.php
+++ b/apps/files_sharing/publicwebdav.php
@@ -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));
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index 2cadb5a..f2578e3 100644
--- a/lib/private/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
@@ -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 {
 
@@ -19,6 +20,11 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
 	protected $fileView;
 
 	/**
+	 * @var \OC\Files\Mount\Manager
+	 */
+	protected $mountManager;
+
+	/**
 	 * Creates the object
 	 *
 	 * This method expects the rootObject to be passed as a parameter
@@ -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();
 			}
 		}
diff --git a/tests/lib/connector/sabre/objecttree.php b/tests/lib/connector/sabre/objecttree.php
index 0075b78..a88e23b 100644
--- a/tests/lib/connector/sabre/objecttree.php
+++ b/tests/lib/connector/sabre/objecttree.php
@@ -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);
 	}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list