summaryrefslogtreecommitdiffstats
path: root/lib/files
diff options
context:
space:
mode:
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 e70eb34b301..32cad6b84b2 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -239,7 +239,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`';
@@ -303,6 +302,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