|
|
|
@ -764,9 +764,15 @@ class OC_Helper { |
|
|
|
public static function maxUploadFilesize($dir) { |
|
|
|
public static function maxUploadFilesize($dir) { |
|
|
|
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); |
|
|
|
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); |
|
|
|
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); |
|
|
|
$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); |
|
|
|
$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){ |
|
|
|
if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){ |
|
|
|
$freeSpace = max($freeSpace, 0); |
|
|
|
$freeSpace = max($freeSpace, 0); |
|
|
|
|
|
|
|
|
|
|
|
@ -806,11 +812,19 @@ class OC_Helper { |
|
|
|
$used = 0; |
|
|
|
$used = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
$free = \OC\Files\Filesystem::free_space(); |
|
|
|
$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) { |
|
|
|
if ($total == 0) { |
|
|
|
$total = 1; // prevent division by zero |
|
|
|
$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); |
|
|
|
return array('free' => $free, 'used' => $used, 'total' => $total, 'relative' => $relative); |
|
|
|
} |
|
|
|
} |
|
|
|
|