Skip to content
Snippets Groups Projects
Commit 32b8fd8f authored by Robin Appelman's avatar Robin Appelman
Browse files

Improve handeling of unlimited max upload size

parent 761540e7
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,7 @@ $totalSize = 0;
foreach ($files['size'] as $size) {
$totalSize += $size;
}
if ($totalSize > $maxUploadFilesize) {
if ($maxUploadFilesize >= 0 and $totalSize > $maxUploadFilesize) {
OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'),
'uploadMaxFilesize' => $maxUploadFilesize,
'maxHumanFilesize' => $maxHumanFilesize)));
......
......@@ -30,6 +30,7 @@
namespace OC\Files;
const FREE_SPACE_UNKNOWN = -2;
const FREE_SPACE_UNLIMITED = -3;
class Filesystem {
public static $loaded = false;
......
......@@ -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){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment