summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-01-29 21:50:48 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-03 09:03:51 +0100
commit2035a179bc319cf3f339e90e14dc01c7a980bc78 (patch)
tree7be503fb1cbe5e0ceabf33ee1ed417e874f417d8 /apps
parent77942ad38afb982c3b7efa841a9bb0b46a0c039a (diff)
downloadnextcloud-server-2035a179bc319cf3f339e90e14dc01c7a980bc78.tar.gz
nextcloud-server-2035a179bc319cf3f339e90e14dc01c7a980bc78.zip
Add store/retrieve checksums
* Add extra db column to filecache * Bump version * Update filecache code to actually handle checksum * Webdav code to store/retrieve checksums
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/connector/sabre/file.php15
-rw-r--r--apps/dav/lib/connector/sabre/filesplugin.php24
2 files changed, 37 insertions, 2 deletions
diff --git a/apps/dav/lib/connector/sabre/file.php b/apps/dav/lib/connector/sabre/file.php
index b925a670405..be313a91e8c 100644
--- a/apps/dav/lib/connector/sabre/file.php
+++ b/apps/dav/lib/connector/sabre/file.php
@@ -214,7 +214,13 @@ class File extends Node implements IFile {
header('X-OC-MTime: accepted');
}
}
+
+ if (isset($request->server['HTTP_OC_CHECKSUM'])) {
+ $checksum = trim($request->server['HTTP_OC_CHECKSUM']);
+ $this->fileView->putFileInfo($this->path, ['checksum' => $checksum]);
+ }
$this->refreshInfo();
+
} catch (StorageNotAvailableException $e) {
throw new ServiceUnavailable("Failed to check file size: " . $e->getMessage());
}
@@ -528,4 +534,13 @@ class File extends Node implements IFile {
throw new \Sabre\DAV\Exception($e->getMessage(), 0, $e);
}
+
+ /**
+ * Get the checksum for this file
+ *
+ * @return string
+ */
+ public function getChecksum() {
+ return $this->info->getChecksum();
+ }
}
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) {