]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use storage_mtime when determining if we can reuse cached data while scanning
authorRobin Appelman <icewind@owncloud.com>
Tue, 14 Jan 2014 12:54:07 +0000 (13:54 +0100)
committerRobin Appelman <icewind@owncloud.com>
Tue, 14 Jan 2014 12:54:07 +0000 (13:54 +0100)
lib/private/files/cache/scanner.php
tests/lib/files/cache/updater.php
tests/lib/files/etagtest.php

index a8c069ee99faf90d87953bd2e3bb8be93f750750..92a4c01841b90324378e37b45f88412a15fc62d5 100644 (file)
@@ -122,7 +122,7 @@ class Scanner extends BasicEmitter {
                                                        $propagateETagChange = true;
                                                }
                                                // only reuse data if the file hasn't explicitly changed
-                                               if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
+                                               if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_mtime']) {
                                                        if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
                                                                $data['size'] = $cacheData['size'];
                                                        }
index 91e384e12afe87f059439e250eb3790a33917bb6..ba103cee6755f2ad152812bea6a7b37323e4d776 100644 (file)
@@ -88,7 +88,7 @@ class Updater extends \PHPUnit_Framework_TestCase {
        public function testWrite() {
                $textSize = strlen("dummy file data\n");
                $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png');
-               $this->cache->put('foo.txt', array('mtime' => 100));
+               $this->cache->put('foo.txt', array('mtime' => 100, 'storage_mtime' => 100));
                $rootCachedData = $this->cache->get('');
                $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
 
index 6c41413c4df27a6f9b60bb42f8750c1b157a39b6..14003896d66e0f79a536e18c75f2204bb7960631 100644 (file)
@@ -11,6 +11,12 @@ namespace Test\Files;
 use OC\Files\Filesystem;
 use OCP\Share;
 
+class TemporaryNoTouch extends \OC\Files\Storage\Temporary {
+       public function touch($path, $mtime = null) {
+               return false;
+       }
+}
+
 class EtagTest extends \PHPUnit_Framework_TestCase {
        private $datadir;
 
@@ -68,6 +74,23 @@ class EtagTest extends \PHPUnit_Framework_TestCase {
                $this->assertEquals($originalEtags, $this->getEtags($files));
        }
 
+       public function testTouchNotSupported() {
+               $storage = new TemporaryNoTouch(array());
+               $scanner = $storage->getScanner();
+               Filesystem::mount($storage, array(), '/test/');
+               $past = time() - 100;
+               $storage->file_put_contents('test', 'foobar');
+               $scanner->scan('');
+               $view = new \OC\Files\View('');
+               $info = $view->getFileInfo('/test/test');
+
+               $view->touch('/test/test', $past);
+               $scanner->scanFile('test', \OC\Files\Cache\Scanner::REUSE_ETAG);
+
+               $info2 = $view->getFileInfo('/test/test');
+               $this->assertEquals($info['etag'], $info2['etag']);
+       }
+
        private function getEtags($files) {
                $etags = array();
                foreach ($files as $file) {