diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-01 08:30:58 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-01 08:30:58 +0100 |
commit | fd4742d4308aef6e1d628e19cece5cc04aaee481 (patch) | |
tree | b8cd4ed9be88680f013ba50a5f878ab6e568ff25 /apps/dav | |
parent | e1acad7ae2a47c3aaeca747ceb734bfbc37c87df (diff) | |
parent | 11215f4e275f7e7d1aafdb8af440550d27562ad8 (diff) | |
download | nextcloud-server-fd4742d4308aef6e1d628e19cece5cc04aaee481.tar.gz nextcloud-server-fd4742d4308aef6e1d628e19cece5cc04aaee481.zip |
Merge pull request #22613 from owncloud/quota-changedavreturnvaluewhennoquotaset
Don't return quota when none set
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/connector/sabre/directory.php | 7 | ||||
-rw-r--r-- | apps/dav/tests/unit/connector/sabre/directory.php | 39 |
2 files changed, 42 insertions, 4 deletions
diff --git a/apps/dav/lib/connector/sabre/directory.php b/apps/dav/lib/connector/sabre/directory.php index 0119879a171..f31eff30b65 100644 --- a/apps/dav/lib/connector/sabre/directory.php +++ b/apps/dav/lib/connector/sabre/directory.php @@ -291,9 +291,14 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node } try { $storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info); + if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { + $free = \OCP\Files\FileInfo::SPACE_UNLIMITED; + } else { + $free = $storageInfo['free']; + } $this->quotaInfo = array( $storageInfo['used'], - $storageInfo['free'] + $free ); return $this->quotaInfo; } catch (\OCP\Files\StorageNotAvailableException $e) { diff --git a/apps/dav/tests/unit/connector/sabre/directory.php b/apps/dav/tests/unit/connector/sabre/directory.php index 317e089925b..c4ddc38b3e1 100644 --- a/apps/dav/tests/unit/connector/sabre/directory.php +++ b/apps/dav/tests/unit/connector/sabre/directory.php @@ -199,15 +199,48 @@ class Directory extends \Test\TestCase { $dir->getChild('.'); } - public function testGetQuotaInfo() { + public function testGetQuotaInfoUnlimited() { $storage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Quota') ->disableOriginalConstructor() ->getMock(); + $storage->expects($this->any()) + ->method('instanceOfStorage') + ->will($this->returnValueMap([ + '\OC\Files\Storage\Shared' => false, + '\OC\Files\Storage\Wrapper\Quota' => false, + ])); + + $storage->expects($this->never()) + ->method('getQuota'); + $storage->expects($this->once()) + ->method('free_space') + ->will($this->returnValue(800)); + + $this->info->expects($this->once()) + ->method('getSize') + ->will($this->returnValue(200)); + + $this->info->expects($this->once()) + ->method('getStorage') + ->will($this->returnValue($storage)); + + $dir = new \OCA\DAV\Connector\Sabre\Directory($this->view, $this->info); + $this->assertEquals([200, -3], $dir->getQuotaInfo()); //200 used, unlimited + } + + public function testGetQuotaInfoSpecific() { + $storage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Quota') + ->disableOriginalConstructor() + ->getMock(); + + $storage->expects($this->any()) ->method('instanceOfStorage') - ->with('\OC\Files\Storage\Wrapper\Quota') - ->will($this->returnValue(true)); + ->will($this->returnValueMap([ + ['\OC\Files\Storage\Shared', false], + ['\OC\Files\Storage\Wrapper\Quota', true], + ])); $storage->expects($this->once()) ->method('getQuota') |