]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge pull request #3764 from owncloud/scanfolder-existing
authoricewind1991 <icewind1991@gmail.com>
Wed, 19 Jun 2013 11:30:55 +0000 (04:30 -0700)
committericewind1991 <icewind1991@gmail.com>
Wed, 19 Jun 2013 11:30:55 +0000 (04:30 -0700)
Improve re-using existing data in the filescanner

1  2 
tests/lib/files/cache/updater.php

index 874a35e2c6f00a281b96a9adcbd6018d3d52a717,198d601b1bb843207330a4102dd62aa44eef6a4d..b2db27e42e0ea52431207f38bdc0ef8664b2a940
@@@ -183,85 -141,4 +182,85 @@@ class Updater extends \PHPUnit_Framewor
                $this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
                $this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
        }
- }
 +
 +      public function testRenameWithMountPoints() {
 +              $storage2 = new \OC\Files\Storage\Temporary(array());
 +              $cache2 = $storage2->getCache();
 +              Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
 +              Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
 +              $this->assertTrue($cache2->inCache('foo.txt'));
 +              $folderCachedData = $this->cache->get('folder');
 +              $substorageCachedData = $cache2->get('');
 +              $fooCachedData = $cache2->get('foo.txt');
 +              Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt');
 +              $this->assertFalse($cache2->inCache('foo.txt'));
 +              $this->assertTrue($cache2->inCache('bar.txt'));
 +              $cachedData = $cache2->get('bar.txt');
 +              $this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
 +              $mtime = $cachedData['mtime'];
 +
 +              $cachedData = $cache2->get('');
 +              $this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($mtime, $cachedData['mtime']);
 +
 +              $cachedData = $this->cache->get('folder');
 +              $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($mtime, $cachedData['mtime']);
 +      }
 +
 +      public function testTouch() {
 +              $rootCachedData = $this->cache->get('');
 +              $fooCachedData = $this->cache->get('foo.txt');
 +              Filesystem::touch('foo.txt');
 +              $cachedData = $this->cache->get('foo.txt');
 +              $this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
 +              $this->assertGreaterThanOrEqual($fooCachedData['mtime'], $cachedData['mtime']);
 +
 +              $cachedData = $this->cache->get('');
 +              $this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
 +              $this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
 +              $rootCachedData = $cachedData;
 +
 +              $time = 1371006070;
 +              $barCachedData = $this->cache->get('folder/bar.txt');
 +              $folderCachedData = $this->cache->get('folder');
 +              Filesystem::touch('folder/bar.txt', $time);
 +              $cachedData = $this->cache->get('folder/bar.txt');
 +              $this->assertNotEquals($barCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($time, $cachedData['mtime']);
 +
 +              $cachedData = $this->cache->get('folder');
 +              $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($time, $cachedData['mtime']);
 +
 +              $cachedData = $this->cache->get('');
 +              $this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($time, $cachedData['mtime']);
 +      }
 +
 +      public function testTouchWithMountPoints() {
 +              $storage2 = new \OC\Files\Storage\Temporary(array());
 +              $cache2 = $storage2->getCache();
 +              Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
 +              Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
 +              $this->assertTrue($cache2->inCache('foo.txt'));
 +              $folderCachedData = $this->cache->get('folder');
 +              $substorageCachedData = $cache2->get('');
 +              $fooCachedData = $cache2->get('foo.txt');
 +              $cachedData = $cache2->get('foo.txt');
 +              $time = 1371006070;
 +              Filesystem::touch('folder/substorage/foo.txt', $time);
 +              $cachedData = $cache2->get('foo.txt');
 +              $this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($time, $cachedData['mtime']);
 +
 +              $cachedData = $cache2->get('');
 +              $this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($time, $cachedData['mtime']);
 +
 +              $cachedData = $this->cache->get('folder');
 +              $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
 +              $this->assertEquals($time, $cachedData['mtime']);
 +      }
 +
+ }