summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-18 08:18:27 -0700
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-18 08:18:27 -0700
commit5b1f857907d8c16fde4c3efbec8b80a22ebe0865 (patch)
treeb2b83f096df46f58461a1a3b39751ff80e3e878d /lib
parentc262ad56b3e842da5bbc5e830dbdb1aadb6e32e5 (diff)
parent8a97afac6f7ba2e552c01ff3cb0477f5beb8fc92 (diff)
downloadnextcloud-server-5b1f857907d8c16fde4c3efbec8b80a22ebe0865.tar.gz
nextcloud-server-5b1f857907d8c16fde4c3efbec8b80a22ebe0865.zip
Merge pull request #2363 from owncloud/uploadsize
Improve behaviour when max upload size is unknown
Diffstat (limited to 'lib')
-rw-r--r--lib/files/filesystem.php1
-rw-r--r--lib/helper.php22
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index d32e082ade9..5c3a0cf93e1 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -30,6 +30,7 @@
namespace OC\Files;
const FREE_SPACE_UNKNOWN = -2;
+const FREE_SPACE_UNLIMITED = -3;
class Filesystem {
public static $loaded = false;
diff --git a/lib/helper.php b/lib/helper.php
index 41985ca57a7..73484ad913f 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -764,9 +764,15 @@ class OC_Helper {
public static function maxUploadFilesize($dir) {
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
- $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
-
$freeSpace = \OC\Files\Filesystem::free_space($dir);
+ if ($upload_max_filesize == 0 and $post_max_size == 0) {
+ $maxUploadFilesize = \OC\Files\FREE_SPACE_UNLIMITED;
+ } elseif ($upload_max_filesize === 0 or $post_max_size === 0) {
+ $maxUploadFilesize = max($upload_max_filesize, $post_max_size); //only the non 0 value counts
+ } else {
+ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+ }
+
if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){
$freeSpace = max($freeSpace, 0);
@@ -806,11 +812,19 @@ class OC_Helper {
$used = 0;
}
$free = \OC\Files\Filesystem::free_space();
- $total = $free + $used;
+ if ($free >= 0){
+ $total = $free + $used;
+ } else {
+ $total = $free; //either unknown or unlimited
+ }
if ($total == 0) {
$total = 1; // prevent division by zero
}
- $relative = round(($used / $total) * 10000) / 100;
+ if ($total >= 0){
+ $relative = round(($used / $total) * 10000) / 100;
+ } else {
+ $relative = 0;
+ }
return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative);
}