Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-06-25 14:01:22 +0300
committerGitHub <noreply@github.com>2018-06-25 14:01:22 +0300
commit587d7cc7d217e2204fd677dcc787e61a6ba0a381 (patch)
treed11c16cbe6f98cee7f64fddf7f4c16b50e728379 /tests
parenta431cc3b58dc5ab2c4c1b47be2e11a35f850631e (diff)
parent4a3471595aec40aca825339a2446d9f9dd8ab963 (diff)
Merge pull request #9526 from Blaok/files-scan-shallow
allow shallow (non-recursive) scan when scanning file storage
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Utils/ScannerTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php
index 1379bc2e906..8748b52f0ca 100644
--- a/tests/lib/Files/Utils/ScannerTest.php
+++ b/tests/lib/Files/Utils/ScannerTest.php
@@ -209,4 +209,35 @@ class ScannerTest extends \Test\TestCase {
$scanner->backgroundScan('');
}
+
+ public function testShallow() {
+ $storage = new Temporary(array());
+ $mount = new MountPoint($storage, '');
+ Filesystem::getMountManager()->addMount($mount);
+ $cache = $storage->getCache();
+
+ $storage->mkdir('folder');
+ $storage->mkdir('folder/subfolder');
+ $storage->file_put_contents('foo.txt', 'qwerty');
+ $storage->file_put_contents('folder/bar.txt', 'qwerty');
+ $storage->file_put_contents('folder/subfolder/foobar.txt', 'qwerty');
+
+ $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), \OC::$server->getLogger());
+ $scanner->addMount($mount);
+
+ $scanner->scan('', $recusive = false);
+ $this->assertTrue($cache->inCache('folder'));
+ $this->assertFalse($cache->inCache('folder/subfolder'));
+ $this->assertTrue($cache->inCache('foo.txt'));
+ $this->assertFalse($cache->inCache('folder/bar.txt'));
+ $this->assertFalse($cache->inCache('folder/subfolder/foobar.txt'));
+
+ $scanner->scan('folder', $recusive = false);
+ $this->assertTrue($cache->inCache('folder'));
+ $this->assertTrue($cache->inCache('folder/subfolder'));
+ $this->assertTrue($cache->inCache('foo.txt'));
+ $this->assertTrue($cache->inCache('folder/bar.txt'));
+ $this->assertFalse($cache->inCache('folder/subfolder/foobar.txt'));
+ }
+
}