summaryrefslogtreecommitdiffstats
path: root/lib/private/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/helper.php')
-rw-r--r--lib/private/helper.php49
1 files changed, 14 insertions, 35 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php
index d8c4650f666..d7ac0b5f4fa 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -78,8 +78,7 @@ class OC_Helper {
* Returns a absolute url to the given app and file.
*/
public static function linkToAbsolute($app, $file, $args = array()) {
- $urlLinkTo = self::linkTo($app, $file, $args);
- return self::makeURLAbsolute($urlLinkTo);
+ return self::linkTo($app, $file, $args);
}
/**
@@ -308,7 +307,7 @@ class OC_Helper {
/**
* @brief Make a computer file size
- * @param string $str file size in a fancy format
+ * @param string $str file size in human readable format
* @return int a file size in bytes
*
* Makes 2kB to 2048.
@@ -338,41 +337,12 @@ class OC_Helper {
$bytes *= $bytes_array[$matches[1]];
}
- $bytes = round($bytes, 2);
+ $bytes = round($bytes);
return $bytes;
}
/**
- * @brief Recursive editing of file permissions
- * @param string $path path to file or folder
- * @param int $filemode unix style file permissions
- * @return bool
- */
- static function chmodr($path, $filemode) {
- if (!is_dir($path))
- return chmod($path, $filemode);
- $dh = opendir($path);
- if(is_resource($dh)) {
- while (($file = readdir($dh)) !== false) {
- if ($file != '.' && $file != '..') {
- $fullpath = $path . '/' . $file;
- if (is_link($fullpath))
- return false;
- elseif (!is_dir($fullpath) && !@chmod($fullpath, $filemode))
- return false; elseif (!self::chmodr($fullpath, $filemode))
- return false;
- }
- }
- closedir($dh);
- }
- if (@chmod($path, $filemode))
- return true;
- else
- return false;
- }
-
- /**
* @brief Recursive copying of folders
* @param string $src source folder
* @param string $dest target folder
@@ -839,7 +809,7 @@ class OC_Helper {
* @return int number of bytes representing
*/
public static function maxUploadFilesize($dir, $freeSpace = null) {
- if (is_null($freeSpace)){
+ if (is_null($freeSpace) || $freeSpace < 0){
$freeSpace = self::freeSpace($dir);
}
return min($freeSpace, self::uploadLimit());
@@ -914,13 +884,22 @@ class OC_Helper {
if ($used < 0) {
$used = 0;
}
- $free = \OC\Files\Filesystem::free_space($path);
+ $quota = 0;
+ // TODO: need a better way to get total space from storage
+ $storage = $rootInfo->getStorage();
+ if ($storage instanceof \OC\Files\Storage\Wrapper\Quota) {
+ $quota = $storage->getQuota();
+ }
+ $free = $storage->free_space('');
if ($free >= 0) {
$total = $free + $used;
} else {
$total = $free; //either unknown or unlimited
}
if ($total > 0) {
+ if ($quota > 0 && $total > $quota) {
+ $total = $quota;
+ }
// prevent division by zero or error codes (negative values)
$relative = round(($used / $total) * 10000) / 100;
} else {