diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-06-10 15:26:18 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-06-12 15:05:45 +0200 |
commit | 6e0a218d1110fcf076cc93277fd97a9d409778c9 (patch) | |
tree | f6dce4f5c29e97e2e6a7939886aede95bf08e7a7 /tests | |
parent | b2fae8a8b783b72717606f5476487c320e24b636 (diff) | |
download | nextcloud-server-6e0a218d1110fcf076cc93277fd97a9d409778c9.tar.gz nextcloud-server-6e0a218d1110fcf076cc93277fd97a9d409778c9.zip |
Repair broken parent link in the scanner
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/scanner.php | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php index 92d75aae907..3b86df51bab 100644 --- a/tests/lib/files/cache/scanner.php +++ b/tests/lib/files/cache/scanner.php @@ -199,7 +199,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(''); @@ -230,4 +230,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']); + } } |