Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/files
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-09-23 18:13:12 +0400
committerAndreas Fischer <bantu@owncloud.com>2013-09-30 01:24:33 +0400
commite01efd3887400ab26341260de48c23cc27a6eb82 (patch)
tree4b92509a2850f188f13b66d92bc3af3af2177941 /lib/files
parente71c7ee635728013e3b97583df838bbc96efbd01 (diff)
Cherry-pick of 5d671a8 onto stable5.
recreate an etag within the scanner if the cache contains an empty etag Conflicts: lib/files/cache/cache.php tests/lib/files/cache/scanner.php
Diffstat (limited to 'lib/files')
-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 76e1ee97727..cb48ab446be 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -210,7 +210,6 @@ class Cache {
$data['path'] = $file;
$data['parent'] = $this->getParentId($file);
$data['name'] = basename($file);
- $data['encrypted'] = isset($data['encrypted']) ? ((int)$data['encrypted']) : 0;
list($queryParts, $params) = $this->buildParts($data);
$queryParts[] = '`storage`';
@@ -272,6 +271,9 @@ class Cache {
$params[] = $this->getMimetypeId(substr($value, 0, strpos($value, '/')));
$queryParts[] = '`mimepart`';
$value = $this->getMimetypeId($value);
+ } 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 d99bd6e2ce0..a87d98eb7b8 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -96,13 +96,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