]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not recheck $cacheData. Move if($reuseExisting) under if($cacheData).
authorAndreas Fischer <bantu@owncloud.com>
Mon, 23 Sep 2013 22:59:23 +0000 (00:59 +0200)
committerAndreas Fischer <bantu@owncloud.com>
Mon, 23 Sep 2013 22:59:23 +0000 (00:59 +0200)
lib/files/cache/scanner.php

index af819c47c6187255e8f820daa0c640959a09fe49..96f84609cf231fb45374c24b0f70a87459eef638 100644 (file)
@@ -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);