aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/lib/helper.php8
-rw-r--r--lib/private/helper.php9
-rw-r--r--lib/public/util.php7
3 files changed, 14 insertions, 10 deletions
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index eaff28178ea..87939d26921 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -5,14 +5,14 @@ namespace OCA\Files;
class Helper
{
public static function buildFileStorageStatistics($dir) {
+ // information about storage capacities
+ $storageInfo = \OC_Helper::getStorageInfo($dir);
+
$l = new \OC_L10N('files');
- $maxUploadFilesize = \OCP\Util::maxUploadFilesize($dir);
+ $maxUploadFilesize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
- // information about storage capacities
- $storageInfo = \OC_Helper::getStorageInfo($dir);
-
return array('uploadMaxFilesize' => $maxUploadFilesize,
'maxHumanFilesize' => $maxHumanFilesize,
'usedSpacePercent' => (int)$storageInfo['relative']);
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 1c8d01c141f..12784c9a5eb 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -824,13 +824,16 @@ class OC_Helper {
/**
* @brief calculates the maximum upload size respecting system settings, free space and user quota
*
- * @param $dir the current folder where the user currently operates
+ * @param string $dir the current folder where the user currently operates
+ * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
* @return number of bytes representing
*/
- public static function maxUploadFilesize($dir) {
+ public static function maxUploadFilesize($dir, $freeSpace = null) {
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
- $freeSpace = \OC\Files\Filesystem::free_space($dir);
+ if (is_null($freeSpace)) {
+ $freeSpace = \OC\Files\Filesystem::free_space($dir);
+ }
if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) {
$maxUploadFilesize = \OC\Files\SPACE_UNLIMITED;
} elseif ((int)$upload_max_filesize === 0 or (int)$post_max_size === 0) {
diff --git a/lib/public/util.php b/lib/public/util.php
index 6317f10a66f..52874bcc954 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -456,10 +456,11 @@ class Util {
/**
* calculates the maximum upload size respecting system settings, free space and user quota
*
- * @param $dir the current folder where the user currently operates
+ * @param string $dir the current folder where the user currently operates
+ * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
* @return number of bytes representing
*/
- public static function maxUploadFilesize($dir) {
- return \OC_Helper::maxUploadFilesize($dir);
+ public static function maxUploadFilesize($dir, $free = null) {
+ return \OC_Helper::maxUploadFilesize($dir, $free);
}
}