@@ -52,6 +52,7 @@ class OC_Helper {
5252
5353 /**
5454 * Creates an absolute url for public use
55+ *
5556 * @param string $service id
5657 * @param bool $add_slash
5758 * @return string the url
@@ -62,13 +63,14 @@ public static function linkToPublic($service, $add_slash = false) {
6263 if ($ service === 'files ' ) {
6364 $ url = OC ::$ server ->getURLGenerator ()->getAbsoluteURL ('/s ' );
6465 } else {
65- $ url = OC ::$ server ->getURLGenerator ()->getAbsoluteURL (OC ::$ server ->getURLGenerator ()->linkTo ('' , 'public.php ' ). '?service= ' . $ service );
66+ $ url = OC ::$ server ->getURLGenerator ()->getAbsoluteURL (OC ::$ server ->getURLGenerator ()->linkTo ('' , 'public.php ' ) . '?service= ' . $ service );
6667 }
6768 return $ url . (($ add_slash && $ service [strlen ($ service ) - 1 ] != '/ ' ) ? '/ ' : '' );
6869 }
6970
7071 /**
7172 * Make a human file size
73+ *
7274 * @param int $bytes file size in bytes
7375 * @return string a human readable file size
7476 *
@@ -104,6 +106,7 @@ public static function humanFileSize($bytes) {
104106
105107 /**
106108 * Make a php file size
109+ *
107110 * @param int $bytes file size in bytes
108111 * @return string a php parseable file size
109112 *
@@ -130,6 +133,7 @@ public static function phpFileSize($bytes) {
130133
131134 /**
132135 * Make a computer file size
136+ *
133137 * @param string $str file size in human readable format
134138 * @return float a file size in bytes
135139 *
@@ -172,6 +176,7 @@ public static function computerFileSize($str) {
172176
173177 /**
174178 * Recursive copying of folders
179+ *
175180 * @param string $src source folder
176181 * @param string $dest target folder
177182 *
@@ -194,6 +199,7 @@ static function copyr($src, $dest) {
194199
195200 /**
196201 * Recursive deletion of folders
202+ *
197203 * @param string $dir path to the folder
198204 * @param bool $deleteSelf if set to false only the content of the folder will be deleted
199205 * @return bool
@@ -393,6 +399,7 @@ public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $
393399
394400 /**
395401 * performs a search in a nested array
402+ *
396403 * @param array $haystack the array to be searched
397404 * @param string $needle the search string
398405 * @param string $index optional, only search this key name
@@ -425,7 +432,7 @@ public static function recursiveArraySearch($haystack, $needle, $index = null) {
425432 * @return int number of bytes representing
426433 */
427434 public static function maxUploadFilesize ($ dir , $ freeSpace = null ) {
428- if (is_null ($ freeSpace ) || $ freeSpace < 0 ){
435+ if (is_null ($ freeSpace ) || $ freeSpace < 0 ) {
429436 $ freeSpace = self ::freeSpace ($ dir );
430437 }
431438 return min ($ freeSpace , self ::uploadLimit ());
@@ -443,7 +450,7 @@ public static function freeSpace($dir) {
443450 $ freeSpace = max ($ freeSpace , 0 );
444451 return $ freeSpace ;
445452 } else {
446- return (INF > 0 )? INF : PHP_INT_MAX ; // work around https://bugs.php.net/bug.php?id=69188
453+ return (INF > 0 ) ? INF : PHP_INT_MAX ; // work around https://bugs.php.net/bug.php?id=69188
447454 }
448455 }
449456
@@ -510,7 +517,7 @@ public static function findBinaryPath($program) {
510517 if (empty ($ paths )) {
511518 $ paths = '/usr/local/bin /usr/bin /opt/bin /bin ' ;
512519 } else {
513- $ paths = str_replace (': ' ,' ' ,getenv ('PATH ' ));
520+ $ paths = str_replace (': ' , ' ' , getenv ('PATH ' ));
514521 }
515522 $ command = 'find ' . $ paths . ' -name ' . escapeshellarg ($ program ) . ' 2> /dev/null ' ;
516523 exec ($ command , $ output , $ returnCode );
@@ -533,6 +540,12 @@ public static function findBinaryPath($program) {
533540 * @throws \OCP\Files\NotFoundException
534541 */
535542 public static function getStorageInfo ($ path , $ rootInfo = null ) {
543+ $ memcache = \OC ::$ server ->getMemCacheFactory ()->create ('storageInfo ' );
544+ $ cacheKey = $ rootInfo ? '__root__ ' . md5 ($ path ) : md5 ($ path );
545+ $ cached = $ memcache ->get ($ cacheKey );
546+ if (is_array ($ cached )) {
547+ return $ cached ;
548+ }
536549 // return storage info without adding mount points
537550 $ includeExtStorage = \OC ::$ server ->getSystemConfig ()->getValue ('quota_include_external_storage ' , false );
538551
@@ -597,10 +610,20 @@ public static function getStorageInfo($path, $rootInfo = null) {
597610 $ ownerId = $ storage ->getOwner ($ path );
598611 $ ownerDisplayName = '' ;
599612 $ owner = \OC ::$ server ->getUserManager ()->get ($ ownerId );
600- if ($ owner ) {
613+ if ($ owner ) {
601614 $ ownerDisplayName = $ owner ->getDisplayName ();
602615 }
603616
617+ $ memcache ->set ($ cacheKey , [
618+ 'free ' => $ free ,
619+ 'used ' => $ used ,
620+ 'quota ' => $ quota ,
621+ 'total ' => $ total ,
622+ 'relative ' => $ relative ,
623+ 'owner ' => $ ownerId ,
624+ 'ownerDisplayName ' => $ ownerDisplayName ,
625+ ], 5 * 60 );
626+
604627 return [
605628 'free ' => $ free ,
606629 'used ' => $ used ,
@@ -645,6 +668,7 @@ private static function getGlobalStorageInfo() {
645668
646669 /**
647670 * Returns whether the config file is set manually to read-only
671+ *
648672 * @return bool
649673 */
650674 public static function isReadOnlyConfigEnabled () {
0 commit comments