summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/connector/sabre/filesplugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/connector/sabre/filesplugin.php')
-rw-r--r--apps/dav/lib/connector/sabre/filesplugin.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/apps/dav/lib/connector/sabre/filesplugin.php b/apps/dav/lib/connector/sabre/filesplugin.php
index ef139eae94a..82d00014905 100644
--- a/apps/dav/lib/connector/sabre/filesplugin.php
+++ b/apps/dav/lib/connector/sabre/filesplugin.php
@@ -47,6 +47,7 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
const OWNER_ID_PROPERTYNAME = '{http://owncloud.org/ns}owner-id';
const OWNER_DISPLAY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}owner-display-name';
+ const CHECKSUM_PROPERTYNAME = '{http://owncloud.org/ns}checksum';
/**
* Reference to main server object
@@ -107,6 +108,7 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
$server->protectedProperties[] = self::DOWNLOADURL_PROPERTYNAME;
$server->protectedProperties[] = self::OWNER_ID_PROPERTYNAME;
$server->protectedProperties[] = self::OWNER_DISPLAY_NAME_PROPERTYNAME;
+ $server->protectedProperties[] = self::CHECKSUM_PROPERTYNAME;
// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
$allowedProperties = ['{DAV:}getetag'];
@@ -178,8 +180,8 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
}
/**
- * Plugin that adds a 'Content-Disposition: attachment' header to all files
- * delivered by SabreDAV.
+ * Add headers to file download
+ *
* @param RequestInterface $request
* @param ResponseInterface $response
*/
@@ -188,7 +190,15 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
$node = $this->tree->getNodeForPath($request->getPath());
if (!($node instanceof IFile)) return;
+ // adds a 'Content-Disposition: attachment' header
$response->addHeader('Content-Disposition', 'attachment');
+
+ //Add OC-Checksum header
+ /** @var $node File */
+ $checksum = $node->getChecksum();
+ if ($checksum !== null) {
+ $response->addHeader('OC-Checksum', $checksum);
+ }
}
/**
@@ -237,6 +247,16 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
}
return false;
});
+
+ $propFind->handle(self::CHECKSUM_PROPERTYNAME, function() use ($node) {
+ $checksum = $node->getChecksum();
+
+ if ($checksum === null) {
+ return '';
+ }
+ return $checksum;
+ });
+
}
if ($node instanceof \OCA\DAV\Connector\Sabre\Directory) {