aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-09-24 00:59:23 +0200
committerAndreas Fischer <bantu@owncloud.com>2013-09-24 00:59:23 +0200
commit21299745846eaa87988dcc5acd6f5604b363b03e (patch)
treee3aa4fad1b40fab638e085c044cb25f25aa4587a
parent235517f111a6d570e43cff1cd3701553412fc1a3 (diff)
downloadnextcloud-server-21299745846eaa87988dcc5acd6f5604b363b03e.tar.gz
nextcloud-server-21299745846eaa87988dcc5acd6f5604b363b03e.zip
Do not recheck $cacheData. Move if($reuseExisting) under if($cacheData).
-rw-r--r--lib/files/cache/scanner.php54
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index af819c47c61..96f84609cf2 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -105,39 +105,39 @@ class Scanner extends BasicEmitter {
$cacheData = $this->cache->get($file);
if ($cacheData) {
$this->permissionsCache->remove($cacheData['fileid']);
- }
- if ($reuseExisting and $cacheData) {
- // 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) {
+ // prevent empty etag
+ $etag = $cacheData['etag'];
+ $propagateETagChange = false;
+ if (empty($etag)) {
+ $etag = $data['etag'];
+ $propagateETagChange = true;
}
- if ($reuseExisting & self::REUSE_ETAG) {
- $data['etag'] = $etag;
- if ($propagateETagChange) {
- $parent = $file;
- while ($parent !== '') {
- $parent = dirname($parent);
- if ($parent === '.') {
- $parent = '';
+ // 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'] = $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),
+ ));
}
- $parentCacheData = $this->cache->get($parent);
- $this->cache->update($parentCacheData['fileid'], array(
- 'etag' => $this->storage->getETag($parent),
- ));
}
}
}
+ // Only update metadata that has changed
+ $newData = array_diff($data, $cacheData);
}
- // Only update metadata that has changed
- $newData = array_diff($data, $cacheData);
}
if (!empty($newData)) {
$this->cache->put($file, $newData);