aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-05-18 15:06:15 +0200
committerRobin Appelman <icewind@owncloud.com>2016-05-23 14:40:35 +0200
commiteca57be3367d9ea462f54cfb227701c8524a6764 (patch)
tree947b57cd8efc796871a8184e2ed00beee95c9ed9 /tests
parent4ba36688346612ec480fd1eea3f192257919cdf7 (diff)
downloadnextcloud-server-eca57be3367d9ea462f54cfb227701c8524a6764.tar.gz
nextcloud-server-eca57be3367d9ea462f54cfb227701c8524a6764.zip
Only recurse into incomplete folders during background scans
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Cache/ScannerTest.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php
index 4a93f3ee014..b44b6f5d0f5 100644
--- a/tests/lib/Files/Cache/ScannerTest.php
+++ b/tests/lib/Files/Cache/ScannerTest.php
@@ -7,6 +7,7 @@
*/
namespace Test\Files\Cache;
+
use OC\Files\Cache\CacheEntry;
/**
@@ -150,6 +151,32 @@ class ScannerTest extends \Test\TestCase {
$this->assertFalse($this->cache->getIncomplete());
}
+ function testBackgroundScanOnlyRecurseIncomplete() {
+ $this->fillTestFolders();
+ $this->storage->mkdir('folder2');
+ $this->storage->file_put_contents('folder2/bar.txt', 'foobar');
+
+ $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
+ $this->assertFalse($this->cache->inCache('folder/bar.txt'));
+ $this->assertFalse($this->cache->inCache('folder/2bar.txt'));
+ $this->assertFalse($this->cache->inCache('folder2/bar.txt'));
+ $this->cache->put('folder2', ['size' => 1]); // mark as complete
+
+ $cachedData = $this->cache->get('');
+ $this->assertEquals(-1, $cachedData['size']);
+
+ $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE_INCOMPLETE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
+
+ $this->assertTrue($this->cache->inCache('folder/bar.txt'));
+ $this->assertTrue($this->cache->inCache('folder/bar.txt'));
+ $this->assertFalse($this->cache->inCache('folder2/bar.txt'));
+
+ $cachedData = $this->cache->get('');
+ $this->assertNotEquals(-1, $cachedData['size']);
+
+ $this->assertFalse($this->cache->getIncomplete());
+ }
+
public function testReuseExisting() {
$this->fillTestFolders();