From 32b8fd8fb7a0deb1461820e6dcfdb6a0114ff980 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 15 Mar 2013 16:31:35 +0100 Subject: Improve handeling of unlimited max upload size --- lib/files/filesystem.php | 1 + lib/helper.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') 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..6ee8a489164 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -764,7 +764,13 @@ 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); + 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); + } $freeSpace = \OC\Files\Filesystem::free_space($dir); if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){ -- cgit v1.2.3 From 319e3f162cab32a2bf373b79d401569ca595f168 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 15 Mar 2013 16:40:36 +0100 Subject: Don't block uploads if the max upload size is unknown --- apps/files/templates/index.php | 2 ++ lib/helper.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index a53df4e2d3e..0d7185bcb78 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -23,8 +23,10 @@ method="post" enctype="multipart/form-data" target="file_upload_target_1"> + = 0):?> + diff --git a/lib/helper.php b/lib/helper.php index 6ee8a489164..687f61520a5 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -764,7 +764,8 @@ 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')); - if ($upload_max_filesize === 0 and $post_max_size === 0) { + $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 @@ -772,7 +773,6 @@ class OC_Helper { $maxUploadFilesize = min($upload_max_filesize, $post_max_size); } - $freeSpace = \OC\Files\Filesystem::free_space($dir); if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){ $freeSpace = max($freeSpace, 0); -- cgit v1.2.3 From 8a97afac6f7ba2e552c01ff3cb0477f5beb8fc92 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 15 Mar 2013 16:46:20 +0100 Subject: Don't show storage space warning when the free space can't be determined --- lib/helper.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/helper.php b/lib/helper.php index 687f61520a5..73484ad913f 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -812,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); } -- cgit v1.2.3