diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-05-24 15:07:23 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-06-03 13:30:59 +0200 |
commit | 63408fa6ef70fb26ef57d93c24a36e325e788b2b (patch) | |
tree | e234a2e91923ee143b0c8feec5857334f75473e5 /tests | |
parent | 2d5bee0661d52629b1ca0b8ec3c57752a3b7d8ed (diff) | |
download | nextcloud-server-63408fa6ef70fb26ef57d93c24a36e325e788b2b.tar.gz nextcloud-server-63408fa6ef70fb26ef57d93c24a36e325e788b2b.zip |
allow deleting "ghost files" trough the View and Node api
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/ViewTest.php | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 2c27bb64a70..59b17b83958 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -2417,7 +2417,7 @@ class ViewTest extends \Test\TestCase { $content = $view->getDirectoryContent('', $filter); - $files = array_map(function(FileInfo $info) { + $files = array_map(function (FileInfo $info) { return $info->getName(); }, $content); sort($files); @@ -2444,4 +2444,53 @@ class ViewTest extends \Test\TestCase { $data = $view->getFileInfo('.'); $this->assertEquals('', $data->getChecksum()); } + + public function testDeleteGhostFile() { + $storage = new Temporary(array()); + $scanner = $storage->getScanner(); + $cache = $storage->getCache(); + $storage->file_put_contents('foo.txt', 'bar'); + \OC\Files\Filesystem::mount($storage, array(), '/test/'); + $scanner->scan(''); + + $storage->unlink('foo.txt'); + + $this->assertTrue($cache->inCache('foo.txt')); + + $view = new \OC\Files\View('/test'); + $rootInfo = $view->getFileInfo(''); + $this->assertEquals(3, $rootInfo->getSize()); + $view->unlink('foo.txt'); + $newInfo = $view->getFileInfo(''); + + $this->assertFalse($cache->inCache('foo.txt')); + $this->assertNotEquals($rootInfo->getEtag(), $newInfo->getEtag()); + $this->assertEquals(0, $newInfo->getSize()); + } + + public function testDeleteGhostFolder() { + $storage = new Temporary(array()); + $scanner = $storage->getScanner(); + $cache = $storage->getCache(); + $storage->mkdir('foo'); + $storage->file_put_contents('foo/foo.txt', 'bar'); + \OC\Files\Filesystem::mount($storage, array(), '/test/'); + $scanner->scan(''); + + $storage->rmdir('foo'); + + $this->assertTrue($cache->inCache('foo')); + $this->assertTrue($cache->inCache('foo/foo.txt')); + + $view = new \OC\Files\View('/test'); + $rootInfo = $view->getFileInfo(''); + $this->assertEquals(3, $rootInfo->getSize()); + $view->rmdir('foo'); + $newInfo = $view->getFileInfo(''); + + $this->assertFalse($cache->inCache('foo')); + $this->assertFalse($cache->inCache('foo/foo.txt')); + $this->assertNotEquals($rootInfo->getEtag(), $newInfo->getEtag()); + $this->assertEquals(0, $newInfo->getSize()); + } } |