summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-09-08 12:56:48 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 11:24:23 +0200
commitb17e836e4586b401864d40e90ecac88f7bdc53ba (patch)
tree1756883d2ee0803c81146e696595e93769f154b5 /apps/dav/lib
parent244de6451b22a1288d3ef698f48fb9c4e78bf15f (diff)
downloadnextcloud-server-b17e836e4586b401864d40e90ecac88f7bdc53ba.tar.gz
nextcloud-server-b17e836e4586b401864d40e90ecac88f7bdc53ba.zip
FilesHome now also returns DAV properties
The files home node must also return DAV properties like etag, permissions, etc for the clients to work like they did with the old endpoint. This fix makes FilesHome extend the Sabre Directory class, this makes the FilesPlugin and other plugins recognize it as a directory and will retrieve the matching properties when applicable. Downstream of https://github.com/owncloud/core/pull/26066 Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php3
-rw-r--r--apps/dav/lib/Files/FilesHome.php55
-rw-r--r--apps/dav/lib/Files/RootCollection.php13
-rw-r--r--apps/dav/lib/Upload/UploadHome.php2
4 files changed, 18 insertions, 55 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index dd5f958ed4c..aa5bacea5bb 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -329,8 +329,7 @@ class FilesPlugin extends ServerPlugin {
});
}
- if ($node instanceof \OCA\DAV\Connector\Sabre\Node
- || $node instanceof \OCA\DAV\Files\FilesHome) {
+ if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
$propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function() use ($node) {
return $this->config->getSystemValue('data-fingerprint', '');
});
diff --git a/apps/dav/lib/Files/FilesHome.php b/apps/dav/lib/Files/FilesHome.php
index a4fb7d285a6..9c8f9835d7c 100644
--- a/apps/dav/lib/Files/FilesHome.php
+++ b/apps/dav/lib/Files/FilesHome.php
@@ -23,11 +23,9 @@ namespace OCA\DAV\Files;
use OCA\DAV\Connector\Sabre\Directory;
use Sabre\DAV\Exception\Forbidden;
-use Sabre\DAV\ICollection;
-use Sabre\DAV\SimpleCollection;
use Sabre\HTTP\URLUtil;
-class FilesHome implements ICollection {
+class FilesHome extends Directory {
/**
* @var array
@@ -41,30 +39,13 @@ class FilesHome implements ICollection {
*/
public function __construct($principalInfo) {
$this->principalInfo = $principalInfo;
- }
-
- function createFile($name, $data = null) {
- return $this->impl()->createFile($name, $data);
- }
-
- function createDirectory($name) {
- $this->impl()->createDirectory($name);
- }
-
- function getChild($name) {
- return $this->impl()->getChild($name);
- }
-
- function getChildren() {
- return $this->impl()->getChildren();
- }
-
- function childExists($name) {
- return $this->impl()->childExists($name);
+ $view = \OC\Files\Filesystem::getView();
+ $rootInfo = $view->getFileInfo('');
+ parent::__construct($view, $rootInfo);
}
function delete() {
- $this->impl()->delete();
+ throw new Forbidden('Permission denied to delete home folder');
}
function getName() {
@@ -75,30 +56,4 @@ class FilesHome implements ICollection {
function setName($name) {
throw new Forbidden('Permission denied to rename this folder');
}
-
- /**
- * Returns the last modification time, as a unix timestamp
- *
- * @return int
- */
- function getLastModified() {
- return $this->impl()->getLastModified();
- }
-
- /**
- * @return Directory
- */
- private function impl() {
- //
- // TODO: we need to mount filesystem of the give user
- //
- $user = \OC::$server->getUserSession()->getUser();
- if ($this->getName() !== $user->getUID()) {
- return new SimpleCollection($this->getName());
- }
- $view = \OC\Files\Filesystem::getView();
- $rootInfo = $view->getFileInfo('');
- $impl = new Directory($view, $rootInfo);
- return $impl;
- }
}
diff --git a/apps/dav/lib/Files/RootCollection.php b/apps/dav/lib/Files/RootCollection.php
index 10459aa8ada..57802d19573 100644
--- a/apps/dav/lib/Files/RootCollection.php
+++ b/apps/dav/lib/Files/RootCollection.php
@@ -22,7 +22,8 @@
namespace OCA\DAV\Files;
use Sabre\DAVACL\AbstractPrincipalCollection;
-use Sabre\DAVACL\IPrincipal;
+use Sabre\HTTP\URLUtil;
+use Sabre\DAV\SimpleCollection;
class RootCollection extends AbstractPrincipalCollection {
@@ -34,9 +35,17 @@ class RootCollection extends AbstractPrincipalCollection {
* supplied by the authentication backend.
*
* @param array $principalInfo
- * @return IPrincipal
+ * @return INode
*/
function getChildForPrincipal(array $principalInfo) {
+ list(,$name) = URLUtil::splitPath($principalInfo['uri']);
+ $user = \OC::$server->getUserSession()->getUser();
+ if ($name !== $user->getUID()) {
+ // a user is only allowed to see their own home contents, so in case another collection
+ // is accessed, we return a simple empty collection for now
+ // in the future this could be considered to be used for accessing shared files
+ return new SimpleCollection($name);
+ }
return new FilesHome($principalInfo);
}
diff --git a/apps/dav/lib/Upload/UploadHome.php b/apps/dav/lib/Upload/UploadHome.php
index 296eb2df3a9..df458e8bc4b 100644
--- a/apps/dav/lib/Upload/UploadHome.php
+++ b/apps/dav/lib/Upload/UploadHome.php
@@ -30,7 +30,7 @@ use Sabre\DAV\ICollection;
class UploadHome implements ICollection {
/**
- * FilesHome constructor.
+ * UploadHome constructor.
*
* @param array $principalInfo
*/