diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-06-12 17:40:44 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-06-12 17:40:44 +0200 |
commit | b595c982d0cc27c9e6e3ee3a04c8f9a567ec0dc8 (patch) | |
tree | 08f8c8818f99e48092486b26d11b3fcb8c519b90 /tests | |
parent | ab7cff6dfd63213746a29f4c0557e92a84561498 (diff) | |
parent | 6b1d8a56bbff688107f86a4adb67495de7c01e9d (diff) | |
download | nextcloud-server-b595c982d0cc27c9e6e3ee3a04c8f9a567ec0dc8.tar.gz nextcloud-server-b595c982d0cc27c9e6e3ee3a04c8f9a567ec0dc8.zip |
Merge pull request #8968 from owncloud/scanner-parent-repair
Repair broken parent link in the scanner
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/scanner.php | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php index 263e5b3445f..0a274631d1c 100644 --- a/tests/lib/files/cache/scanner.php +++ b/tests/lib/files/cache/scanner.php @@ -32,7 +32,6 @@ class Scanner extends \PHPUnit_Framework_TestCase { function tearDown() { if ($this->cache) { - $ids = $this->cache->getAll(); $this->cache->clear(); } } @@ -199,7 +198,7 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->cache->inCache('folder/bar.txt')); } - public function testScanRemovedFile(){ + public function testScanRemovedFile() { $this->fillTestFolders(); $this->scanner->scan(''); @@ -233,4 +232,52 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertInternalType('string', $newData0['etag']); $this->assertNotEmpty($newData0['etag']); } + + public function testRepairParent() { + $this->fillTestFolders(); + $this->scanner->scan(''); + $this->assertTrue($this->cache->inCache('folder/bar.txt')); + $oldFolderId = $this->cache->getId('folder'); + + // delete the folder without removing the childs + $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?'; + \OC_DB::executeAudited($sql, array($oldFolderId)); + + $cachedData = $this->cache->get('folder/bar.txt'); + $this->assertEquals($oldFolderId, $cachedData['parent']); + $this->assertFalse($this->cache->inCache('folder')); + + $this->scanner->scan(''); + + $this->assertTrue($this->cache->inCache('folder')); + $newFolderId = $this->cache->getId('folder'); + $this->assertNotEquals($oldFolderId, $newFolderId); + + $cachedData = $this->cache->get('folder/bar.txt'); + $this->assertEquals($newFolderId, $cachedData['parent']); + } + + public function testRepairParentShallow() { + $this->fillTestFolders(); + $this->scanner->scan(''); + $this->assertTrue($this->cache->inCache('folder/bar.txt')); + $oldFolderId = $this->cache->getId('folder'); + + // delete the folder without removing the childs + $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?'; + \OC_DB::executeAudited($sql, array($oldFolderId)); + + $cachedData = $this->cache->get('folder/bar.txt'); + $this->assertEquals($oldFolderId, $cachedData['parent']); + $this->assertFalse($this->cache->inCache('folder')); + + $this->scanner->scan('folder', \OC\Files\Cache\Scanner::SCAN_SHALLOW); + + $this->assertTrue($this->cache->inCache('folder')); + $newFolderId = $this->cache->getId('folder'); + $this->assertNotEquals($oldFolderId, $newFolderId); + + $cachedData = $this->cache->get('folder/bar.txt'); + $this->assertEquals($newFolderId, $cachedData['parent']); + } } |