Merge pull request #7808 from owncloud/quota-usequotaevenwhenfreespaceunknown
Still return quota value when free space is unknown
This commit is contained in:
commit
316a22b463
|
@ -69,7 +69,14 @@ class Quota extends Wrapper {
|
|||
return \OC\Files\SPACE_NOT_COMPUTED;
|
||||
} else {
|
||||
$free = $this->storage->free_space($path);
|
||||
return min($free, (max($this->quota - $used, 0)));
|
||||
$quotaFree = max($this->quota - $used, 0);
|
||||
// if free space is known
|
||||
if ($free >= 0) {
|
||||
$free = min($free, $quotaFree);
|
||||
} else {
|
||||
$free = $quotaFree;
|
||||
}
|
||||
return $free;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,24 @@ class Quota extends \Test\Files\Storage\Storage {
|
|||
$this->assertEquals(6, $instance->free_space(''));
|
||||
}
|
||||
|
||||
public function testFreeSpaceWithUnknownDiskSpace() {
|
||||
$storage = $this->getMock(
|
||||
'\OC\Files\Storage\Local',
|
||||
array('free_space'),
|
||||
array(array('datadir' => $this->tmpDir))
|
||||
);
|
||||
$storage->expects($this->any())
|
||||
->method('free_space')
|
||||
->will($this->returnValue(-2));
|
||||
$storage->getScanner()->scan('');
|
||||
|
||||
$instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 9));
|
||||
$instance->getCache()->put(
|
||||
'', array('size' => 3, 'unencrypted_size' => 0)
|
||||
);
|
||||
$this->assertEquals(6, $instance->free_space(''));
|
||||
}
|
||||
|
||||
public function testFreeSpaceWithUsedSpaceAndEncryption() {
|
||||
$instance = $this->getLimitedStorage(9);
|
||||
$instance->getCache()->put(
|
||||
|
|
Loading…
Reference in New Issue