[Pkg-owncloud-commits] [owncloud] 64/134: Still return quota value when free space is unknown
David Prévot
taffit at moszumanska.debian.org
Fri Apr 18 21:44:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit bb995c53c5f8e871b3e7a63d33ea55a755532108
Author: Vincent Petry <pvince81 at owncloud.com>
Date: Thu Mar 20 17:36:50 2014 +0100
Still return quota value when free space is unknown
Fixed the quota storage wrapper to correctly return the quota value
when the free space is not known (which usually happens when the
disk_free_space function is disabled)
Backport of 66bc0f0 from master
---
lib/private/files/storage/wrapper/quota.php | 9 ++++++++-
tests/lib/files/storage/wrapper/quota.php | 18 ++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php
index 7409414..fb788b2 100644
--- a/lib/private/files/storage/wrapper/quota.php
+++ b/lib/private/files/storage/wrapper/quota.php
@@ -53,7 +53,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;
}
}
}
diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php
index e9727ba..ccf2a8c 100644
--- a/tests/lib/files/storage/wrapper/quota.php
+++ b/tests/lib/files/storage/wrapper/quota.php
@@ -58,6 +58,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(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list