summaryrefslogtreecommitdiffstats
path: root/lib/private/files/fileinfo.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-11-25 12:49:54 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-11-25 12:49:54 +0100
commit50f6817ce99f3870e1e8dea92eaa35a0c40553ba (patch)
treeaf5dc3fbc1755312e2c8dbe28eab6b3a13d1693e /lib/private/files/fileinfo.php
parent60682e17047df19c9486bfc21a993e08bbfce5ce (diff)
parenta95d4c2b22e2cf0deb4958bc3aa3b20ed9d0463c (diff)
downloadnextcloud-server-50f6817ce99f3870e1e8dea92eaa35a0c40553ba.tar.gz
nextcloud-server-50f6817ce99f3870e1e8dea92eaa35a0c40553ba.zip
Merge pull request #20439 from owncloud/etag-propagate-in-storage
Take submount etag into account for folder etags
Diffstat (limited to 'lib/private/files/fileinfo.php')
-rw-r--r--lib/private/files/fileinfo.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php
index bb810dd45ed..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'];
+ }
}
/**
@@ -285,4 +297,26 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
public function getOwner() {
return $this->owner;
}
+
+ /**
+ * Add a cache entry which is the child of this folder
+ *
+ * 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, $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;
+ }
+ }
}