diff options
author | icewind1991 <icewind1991@gmail.com> | 2013-06-19 04:30:55 -0700 |
---|---|---|
committer | icewind1991 <icewind1991@gmail.com> | 2013-06-19 04:30:55 -0700 |
commit | cb41b88520498ca2325aedd180c3fe29474c83bf (patch) | |
tree | af61f1cc9762d88e8d39717770452904f59f90df /tests | |
parent | 8406d3f7b1a8e33c4fbd378660f1510a1d44346d (diff) | |
parent | 0b74e71de83801475a029951cdc85d2942307856 (diff) | |
download | nextcloud-server-cb41b88520498ca2325aedd180c3fe29474c83bf.tar.gz nextcloud-server-cb41b88520498ca2325aedd180c3fe29474c83bf.zip |
Merge pull request #3764 from owncloud/scanfolder-existing
Improve re-using existing data in the filescanner
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/scanner.php | 20 | ||||
-rw-r--r-- | tests/lib/files/cache/updater.php | 5 |
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php index 3885c99e6d3..3dacefa2b80 100644 --- a/tests/lib/files/cache/scanner.php +++ b/tests/lib/files/cache/scanner.php @@ -104,7 +104,7 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertNotEquals($cachedDataFolder['size'], -1); } - function testBackgroundScan(){ + function testBackgroundScan() { $this->fillTestFolders(); $this->storage->mkdir('folder2'); $this->storage->file_put_contents('folder2/bar.txt', 'foobar'); @@ -126,6 +126,24 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->cache->getIncomplete()); } + public function testReuseExisting() { + $this->fillTestFolders(); + + $this->scanner->scan(''); + $oldData = $this->cache->get(''); + $this->storage->unlink('folder/bar.txt'); + $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE); + $newData = $this->cache->get(''); + $this->assertNotEquals($oldData['etag'], $newData['etag']); + $this->assertEquals($oldData['size'], $newData['size']); + + $oldData = $newData; + $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG); + $newData = $this->cache->get(''); + $this->assertEquals($oldData['etag'], $newData['etag']); + $this->assertEquals(-1, $newData['size']); + } + function setUp() { $this->storage = new \OC\Files\Storage\Temporary(array()); $this->scanner = new \OC\Files\Cache\Scanner($this->storage); diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php index 874a35e2c6f..b2db27e42e0 100644 --- a/tests/lib/files/cache/updater.php +++ b/tests/lib/files/cache/updater.php @@ -69,6 +69,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)); $rootCachedData = $this->cache->get(''); $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']); @@ -77,11 +78,9 @@ class Updater extends \PHPUnit_Framework_TestCase { $cachedData = $this->cache->get('foo.txt'); $this->assertEquals(3, $cachedData['size']); $this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']); - $mtime = $cachedData['mtime']; $cachedData = $this->cache->get(''); $this->assertEquals(2 * $textSize + $imageSize + 3, $cachedData['size']); $this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']); - $this->assertGreaterThanOrEqual($rootCachedData['mtime'], $mtime); $rootCachedData = $cachedData; $this->assertFalse($this->cache->inCache('bar.txt')); @@ -264,4 +263,4 @@ class Updater extends \PHPUnit_Framework_TestCase { $this->assertEquals($time, $cachedData['mtime']); } -}
\ No newline at end of file +} |