diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-29 21:50:48 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-02-03 09:03:51 +0100 |
commit | 2035a179bc319cf3f339e90e14dc01c7a980bc78 (patch) | |
tree | 7be503fb1cbe5e0ceabf33ee1ed417e874f417d8 /lib/private | |
parent | 77942ad38afb982c3b7efa841a9bb0b46a0c039a (diff) | |
download | nextcloud-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 'lib/private')
-rw-r--r-- | lib/private/files/cache/cache.php | 17 | ||||
-rw-r--r-- | lib/private/files/fileinfo.php | 7 | ||||
-rw-r--r-- | lib/private/files/node/file.php | 7 | ||||
-rw-r--r-- | lib/private/files/node/node.php | 4 |
4 files changed, 28 insertions, 7 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index 30e00b6080c..cbe48f21bd8 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -121,7 +121,7 @@ class Cache implements ICache { $params = array($file); } $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, - `storage_mtime`, `encrypted`, `etag`, `permissions` + `storage_mtime`, `encrypted`, `etag`, `permissions`, `checksum` FROM `*PREFIX*filecache` ' . $where; $result = $this->connection->executeQuery($sql, $params); $data = $result->fetch(); @@ -177,7 +177,7 @@ class Cache implements ICache { public function getFolderContentsById($fileId) { if ($fileId > -1) { $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, - `storage_mtime`, `encrypted`, `etag`, `permissions` + `storage_mtime`, `encrypted`, `etag`, `permissions`, `checksum` FROM `*PREFIX*filecache` WHERE `parent` = ? ORDER BY `name` ASC'; $result = $this->connection->executeQuery($sql, [$fileId]); $files = $result->fetchAll(); @@ -287,7 +287,10 @@ class Cache implements ICache { // don't update if the data we try to set is the same as the one in the record // some databases (Postgres) don't like superfluous updates $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' . - 'WHERE (' . implode(' <> ? OR ', $queryParts) . ' <> ? ) AND `fileid` = ? '; + 'WHERE (' . + implode(' <> ? OR ', $queryParts) . ' <> ? OR ' . + implode(' IS NULL OR ', $queryParts) . ' IS NULL' . + ') AND `fileid` = ? '; $this->connection->executeQuery($sql, $params); } @@ -303,7 +306,7 @@ class Cache implements ICache { protected function buildParts(array $data) { $fields = array( 'path', 'parent', 'name', 'mimetype', 'size', 'mtime', 'storage_mtime', 'encrypted', - 'etag', 'permissions'); + 'etag', 'permissions', 'checksum'); $doNotCopyStorageMTime = false; if (array_key_exists('mtime', $data) && $data['mtime'] === null) { @@ -567,7 +570,7 @@ class Cache implements ICache { $sql = ' SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, - `etag`, `permissions` + `etag`, `permissions`, `checksum` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `name` ILIKE ?'; $result = $this->connection->executeQuery($sql, @@ -598,7 +601,7 @@ class Cache implements ICache { } else { $where = '`mimepart` = ?'; } - $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `etag`, `permissions` + $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `etag`, `permissions`, `checksum` FROM `*PREFIX*filecache` WHERE ' . $where . ' AND `storage` = ?'; $mimetype = $this->mimetypeLoader->getId($mimetype); $result = $this->connection->executeQuery($sql, array($mimetype, $this->getNumericStorageId())); @@ -625,7 +628,7 @@ class Cache implements ICache { public function searchByTag($tag, $userId) { $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' . '`mimetype`, `mimepart`, `size`, `mtime`, ' . - '`encrypted`, `etag`, `permissions` ' . + '`encrypted`, `etag`, `permissions`, `checksum` ' . 'FROM `*PREFIX*filecache` `file`, ' . '`*PREFIX*vcategory_to_object` `tagmap`, ' . '`*PREFIX*vcategory` `tag` ' . diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php index 1e6fe474f7b..f22e1099e26 100644 --- a/lib/private/files/fileinfo.php +++ b/lib/private/files/fileinfo.php @@ -327,4 +327,11 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions; } } + + /** + * @inheritdoc + */ + public function getChecksum() { + return $this->data['checksum']; + } } diff --git a/lib/private/files/node/file.php b/lib/private/files/node/file.php index c3d18cdb358..cf163b9b763 100644 --- a/lib/private/files/node/file.php +++ b/lib/private/files/node/file.php @@ -164,4 +164,11 @@ class File extends Node implements \OCP\Files\File { public function hash($type, $raw = false) { return $this->view->hash($type, $this->path, $raw); } + + /** + * @inheritdoc + */ + public function getChecksum() { + return $this->fileInfo->getChecksum(); + } } diff --git a/lib/private/files/node/node.php b/lib/private/files/node/node.php index 7769f15ee59..9feccac50bc 100644 --- a/lib/private/files/node/node.php +++ b/lib/private/files/node/node.php @@ -351,4 +351,8 @@ class Node implements \OCP\Files\Node { public function getOwner() { return $this->getFileInfo()->getOwner(); } + + public function getChecksum() { + return; + } } |