diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-03-04 13:28:48 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-03-04 13:28:48 +0100 |
commit | 5ef37c28d1dc73c1fc16a731954b84b46c1943f4 (patch) | |
tree | a474078c1947e12293b4df26bb0d3068d5804a93 | |
parent | 331fc55e2d876123580986264f47318afcf9352b (diff) | |
download | nextcloud-server-5ef37c28d1dc73c1fc16a731954b84b46c1943f4.tar.gz nextcloud-server-5ef37c28d1dc73c1fc16a731954b84b46c1943f4.zip |
Remove the need for a custom SabreDav server constructor
-rw-r--r-- | apps/files/appinfo/remote.php | 8 | ||||
-rw-r--r-- | lib/private/connector/sabre/objecttree.php | 19 | ||||
-rw-r--r-- | lib/private/connector/sabre/server.php | 11 |
3 files changed, 20 insertions, 18 deletions
diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index 1922bc4fcdd..d9c667c0106 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -35,7 +35,8 @@ $lockBackend = new OC_Connector_Sabre_Locks(); $requestBackend = new OC_Connector_Sabre_Request(); // Fire up server -$server = new OC_Connector_Sabre_Server(); +$objectTree = new \OC\Connector\Sabre\ObjectTree(); +$server = new OC_Connector_Sabre_Server($objectTree); $server->httpRequest = $requestBackend; $server->setBaseUri($baseuri); @@ -49,14 +50,13 @@ $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin()); $server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav')); // wait with registering these until auth is handled and the filesystem is setup -$server->subscribeEvent('beforeMethod', function () use ($server) { +$server->subscribeEvent('beforeMethod', function () use ($server, $objectTree) { $view = \OC\Files\Filesystem::getView(); $rootInfo = $view->getFileInfo(''); // Create ownCloud Dir $rootDir = new OC_Connector_Sabre_Directory($view, $rootInfo); - $objectTree = new \OC\Connector\Sabre\ObjectTree($rootDir, $view); - $server->setObjectTree($objectTree); + $objectTree->init($rootDir, $view); $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 d176d3333f8..76f4817d3ba 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -22,12 +22,16 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { * Creates the object * * This method expects the rootObject to be passed as a parameter - * + */ + public function __construct() { + } + + /** * @param \Sabre_DAV_ICollection $rootNode * @param \OC\Files\View $view */ - public function __construct(\Sabre_DAV_ICollection $rootNode, $view) { - parent::__construct($rootNode); + public function init(\Sabre_DAV_ICollection $rootNode, \OC\Files\View $view) { + $this->rootNode = $rootNode; $this->fileView = $view; } @@ -39,6 +43,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { * @return \Sabre_DAV_INode */ public function getNodeForPath($path) { + if (!$this->fileView) { + throw new \Sabre_DAV_Exception_ServiceUnavailable('filesystem not setup'); + } $path = trim($path, '/'); if (isset($this->cache[$path])) { @@ -94,6 +101,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { * @return int */ public function move($sourcePath, $destinationPath) { + if (!$this->fileView) { + throw new \Sabre_DAV_Exception_ServiceUnavailable('filesystem not setup'); + } $sourceNode = $this->getNodeForPath($sourcePath); if ($sourceNode instanceof \Sabre_DAV_ICollection and $this->nodeExists($destinationPath)) { @@ -150,6 +160,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { * @return void */ public function copy($source, $destination) { + if (!$this->fileView) { + throw new \Sabre_DAV_Exception_ServiceUnavailable('filesystem not setup'); + } if ($this->fileView->is_file($source)) { $this->fileView->copy($source, $destination); diff --git a/lib/private/connector/sabre/server.php b/lib/private/connector/sabre/server.php index bb7a7171d1f..b09237fb3cd 100644 --- a/lib/private/connector/sabre/server.php +++ b/lib/private/connector/sabre/server.php @@ -27,17 +27,6 @@ * @see Sabre_DAV_Server */ class OC_Connector_Sabre_Server extends Sabre_DAV_Server { - /** - * Sets up the server - * - * Unlike Sabre_DAV_Server's constructor this does not take an INode or ObjectTree as argument, - * the object tree needs to be set later with setObjectTree - */ - public function __construct() { - $this->httpResponse = new Sabre_HTTP_Response(); - $this->httpRequest = new Sabre_HTTP_Request(); - - } public function setObjectTree($tree) { $this->tree = $tree; |