mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
Reuse the calculated free_space in buildFileStorageStatistics
This commit is contained in:
parent
d182b4f59f
commit
3c1ab66eda
3 changed files with 15 additions and 11 deletions
|
|
@ -5,14 +5,14 @@ namespace OCA\Files;
|
|||
class Helper
|
||||
{
|
||||
public static function buildFileStorageStatistics($dir) {
|
||||
$l = new \OC_L10N('files');
|
||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize($dir);
|
||||
$maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
|
||||
$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
|
||||
|
||||
// information about storage capacities
|
||||
$storageInfo = \OC_Helper::getStorageInfo($dir);
|
||||
|
||||
$l = new \OC_L10N('files');
|
||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
|
||||
$maxHumanFilesize = \OCP\Util::humanFileSize($maxUploadFilesize);
|
||||
$maxHumanFilesize = $l->t('Upload') . ' max. ' . $maxHumanFilesize;
|
||||
|
||||
return array('uploadMaxFilesize' => $maxUploadFilesize,
|
||||
'maxHumanFilesize' => $maxHumanFilesize,
|
||||
'usedSpacePercent' => (int)$storageInfo['relative']);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue