diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-11-10 16:14:08 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-11-19 13:32:00 +0100 |
commit | 888df3933df7f3588de11085035d2d3ae9292fb0 (patch) | |
tree | b7976666e9249b0be163b57fb064f3a1ade26919 /lib/private/files/fileinfo.php | |
parent | d006a7c723e4c51a4132b0f8817392bf1f3cd534 (diff) | |
download | nextcloud-server-888df3933df7f3588de11085035d2d3ae9292fb0.tar.gz nextcloud-server-888df3933df7f3588de11085035d2d3ae9292fb0.zip |
take the etag of child mounts into account for the folder etag
this replaces shared etag propagation
Diffstat (limited to 'lib/private/files/fileinfo.php')
-rw-r--r-- | lib/private/files/fileinfo.php | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php index 2d2ef325d38..5b5e8697004 100644 --- a/lib/private/files/fileinfo.php +++ b/lib/private/files/fileinfo.php @@ -62,6 +62,11 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { private $owner; /** + * @var string[] + */ + private $childEtags = []; + + /** * @param string|boolean $path * @param Storage\Storage $storage * @param string $internalPath @@ -93,6 +98,8 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { public function offsetGet($offset) { if ($offset === 'type') { return $this->getType(); + } else if ($offset === 'etag') { + return $this->getEtag(); } elseif (isset($this->data[$offset])) { return $this->data[$offset]; } else { @@ -153,7 +160,12 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * @return string */ public function getEtag() { - return $this->data['etag']; + if (count($this->childEtags) > 0) { + $combinedEtag = $this->data['etag'] . '::' . implode('::', $this->childEtags); + return md5($combinedEtag); + } else { + return $this->data['etag']; + } } /** @@ -292,8 +304,19 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * Sets the size, etag and size to for cross-storage childs * * @param array $data cache entry for the child + * @param string $entryPath full path of the child entry */ - public function addSubEntry($data) { + public function addSubEntry($data, $entryPath) { $this->data['size'] += isset($data['size']) ? $data['size'] : 0; + if (isset($data['mtime'])) { + $this->data['mtime'] = max($this->data['mtime'], $data['mtime']); + } + if (isset($data['etag'])) { + // prefix the etag with the relative path of the subentry to propagate etag on mount moves + $relativeEntryPath = substr($entryPath, strlen($this->getPath())); + // attach the permissions to propagate etag on permision changes of submounts + $permissions = isset($data['permissions']) ? $data['permissions'] : 0; + $this->childEtags[] = $relativeEntryPath . '/' . $data['etag'] . $permissions; + } } } |