summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorAri Selseng <ari@selseng.net>2019-03-01 23:52:58 +0100
committerBackportbot <backportbot-noreply@rullzer.com>2019-03-08 08:14:33 +0000
commit264b4ad3a911ba629e2a7551d64482aaaf707b99 (patch)
tree0e16aad414324e88ceb1980e84c0cfd06a74bb35 /tests/lib
parent95bc1a0198bdd580679315cf144c8451c4056d57 (diff)
downloadnextcloud-server-264b4ad3a911ba629e2a7551d64482aaaf707b99.tar.gz
nextcloud-server-264b4ad3a911ba629e2a7551d64482aaaf707b99.zip
Avoid calculating folder size for parent that needs scan.
Signed-off-by: Ari Selseng <ari@selseng.net>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Files/Cache/ScannerTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php
index 736df2174d1..0f5335f4416 100644
--- a/tests/lib/Files/Cache/ScannerTest.php
+++ b/tests/lib/Files/Cache/ScannerTest.php
@@ -203,6 +203,44 @@ class ScannerTest extends \Test\TestCase {
$this->assertFalse($this->cache->getIncomplete());
}
+ public function testBackgroundScanNestedIncompleteFolders() {
+ $this->storage->mkdir('folder');
+ $this->scanner->backgroundScan();
+
+ $this->storage->mkdir('folder/subfolder1');
+ $this->storage->mkdir('folder/subfolder2');
+
+ $this->storage->mkdir('folder/subfolder1/subfolder3');
+ $this->cache->put('folder', ['size' => -1]);
+ $this->cache->put('folder/subfolder1', ['size' => -1]);
+
+ // do a scan to get the folders into the cache.
+ $this->scanner->backgroundScan();
+
+ $this->assertTrue($this->cache->inCache('folder/subfolder1/subfolder3'));
+
+ $this->storage->file_put_contents('folder/subfolder1/bar1.txt', 'foobar');
+ $this->storage->file_put_contents('folder/subfolder1/subfolder3/bar3.txt', 'foobar');
+ $this->storage->file_put_contents('folder/subfolder2/bar2.txt', 'foobar');
+
+ //mark folders as incomplete.
+ $this->cache->put('folder/subfolder1', ['size' => -1]);
+ $this->cache->put('folder/subfolder2', ['size' => -1]);
+ $this->cache->put('folder/subfolder1/subfolder3', ['size' => -1]);
+
+ $this->scanner->backgroundScan();
+
+ $this->assertTrue($this->cache->inCache('folder/subfolder1/bar1.txt'));
+ $this->assertTrue($this->cache->inCache('folder/subfolder2/bar2.txt'));
+ $this->assertTrue($this->cache->inCache('folder/subfolder1/subfolder3/bar3.txt'));
+
+ //check if folder sizes are correct.
+ $this->assertEquals(18, $this->cache->get('folder')['size']);
+ $this->assertEquals(12, $this->cache->get('folder/subfolder1')['size']);
+ $this->assertEquals(6, $this->cache->get('folder/subfolder1/subfolder3')['size']);
+ $this->assertEquals(6, $this->cache->get('folder/subfolder2')['size']);
+ }
+
public function testReuseExisting() {
$this->fillTestFolders();