summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-09-23 07:13:12 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-09-23 07:13:12 -0700
commit5d671a84b22079f12a993c02993db39cef008230 (patch)
treea3572ff0079ff8297465ae7c2525516f4fb6b465 /lib
parent46f64cc39a32494d2b83fecb2acbe265d3f77271 (diff)
parentd9a36ee82ec3bffb83515248b69c287f5fd0170f (diff)
downloadnextcloud-server-5d671a84b22079f12a993c02993db39cef008230.tar.gz
nextcloud-server-5d671a84b22079f12a993c02993db39cef008230.zip
Merge pull request #4869 from owncloud/fixing-4866-master
recreate an etag within the scanner if the cache contains an empty etag
Diffstat (limited to 'lib')
-rw-r--r--lib/files/cache/cache.php4
-rw-r--r--lib/files/cache/scanner.php23
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 39e36684b7b..e69733727af 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -201,7 +201,6 @@ class Cache {
$data['path'] = $file;
$data['parent'] = $this->getParentId($file);
$data['name'] = \OC_Util::basename($file);
- $data['encrypted'] = isset($data['encrypted']) ? ((int)$data['encrypted']) : 0;
list($queryParts, $params) = $this->buildParts($data);
$queryParts[] = '`storage`';
@@ -265,6 +264,9 @@ class Cache {
$params[] = $value;
$queryParts[] = '`mtime`';
}
+ } elseif ($name === 'encrypted') {
+ // Boolean to integer conversion
+ $value = $value ? 1 : 0;
}
$params[] = $value;
$queryParts[] = '`' . $name . '`';
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index dcc5d8c5581..a986c1ca725 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -97,13 +97,34 @@ class Scanner extends BasicEmitter {
}
$newData = $data;
if ($reuseExisting and $cacheData = $this->cache->get($file)) {
+ // prevent empty etag
+ $etag = $cacheData['etag'];
+ $propagateETagChange = false;
+ if (empty($etag)) {
+ $etag = $data['etag'];
+ $propagateETagChange = true;
+ }
+
// only reuse data if the file hasn't explicitly changed
if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
$data['size'] = $cacheData['size'];
}
if ($reuseExisting & self::REUSE_ETAG) {
- $data['etag'] = $cacheData['etag'];
+ $data['etag'] = $etag;
+ if ($propagateETagChange) {
+ $parent = $file;
+ while ($parent !== '') {
+ $parent = dirname($parent);
+ if ($parent === '.') {
+ $parent = '';
+ }
+ $parentCacheData = $this->cache->get($parent);
+ $this->cache->update($parentCacheData['fileid'], array(
+ 'etag' => $this->storage->getETag($parent),
+ ));
+ }
+ }
}
}
// Only update metadata that has changed