summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-03-08 17:31:54 +0100
committerGitHub <noreply@github.com>2019-03-08 17:31:54 +0100
commit42cd3876d41dd6a76c44466f73a4231f6f970881 (patch)
tree7a8f61ed54303016e606bc527fde30cb8d44c93d /tests
parente957b0a271a14e7247eda6fc8f0697dbdec65b31 (diff)
parent264b4ad3a911ba629e2a7551d64482aaaf707b99 (diff)
downloadnextcloud-server-42cd3876d41dd6a76c44466f73a4231f6f970881.tar.gz
nextcloud-server-42cd3876d41dd6a76c44466f73a4231f6f970881.zip
Merge pull request #14597 from nextcloud/backport/14425/stable15
[stable15] Do not calculate folder size for parent that also needs proper scan, fixes #3524
Diffstat (limited to 'tests')
-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();