4444 *
4545 */
4646use bantu \IniGetWrapper \IniGetWrapper ;
47+ use OC \Files \Filesystem ;
4748use OCP \Files \Mount \IMountPoint ;
49+ use OCP \ICacheFactory ;
4850use OCP \IUser ;
4951use Symfony \Component \Process \ExecutableFinder ;
5052
@@ -486,9 +488,20 @@ public static function findBinaryPath($program) {
486488 * @throws \OCP\Files\NotFoundException
487489 */
488490 public static function getStorageInfo ($ path , $ rootInfo = null , $ includeMountPoints = true ) {
491+ /** @var ICacheFactory $cacheFactory */
492+ $ cacheFactory = \OC ::$ server ->get (ICacheFactory::class);
493+ $ memcache = $ cacheFactory ->createLocal ('storage_info ' );
494+
489495 // return storage info without adding mount points
490496 $ includeExtStorage = \OC ::$ server ->getSystemConfig ()->getValue ('quota_include_external_storage ' , false );
491497
498+ $ fullPath = Filesystem::getView ()->getAbsolutePath ($ path );
499+ $ cacheKey = $ fullPath . ':: ' . ($ includeMountPoints ? 'include ' : 'exclude ' );
500+ $ cached = $ memcache ->get ($ cacheKey );
501+ if ($ cached ) {
502+ return $ cached ;
503+ }
504+
492505 if (!$ rootInfo ) {
493506 $ rootInfo = \OC \Files \Filesystem::getFileInfo ($ path , $ includeExtStorage ? 'ext ' : false );
494507 }
@@ -559,7 +572,7 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
559572 [,,,$ mountPoint ] = explode ('/ ' , $ mount ->getMountPoint (), 4 );
560573 }
561574
562- return [
575+ $ info = [
563576 'free ' => $ free ,
564577 'used ' => $ used ,
565578 'quota ' => $ quota ,
@@ -570,6 +583,10 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin
570583 'mountType ' => $ mount ->getMountType (),
571584 'mountPoint ' => trim ($ mountPoint , '/ ' ),
572585 ];
586+
587+ $ memcache ->set ($ cacheKey , $ info , 5 * 60 );
588+
589+ return $ info ;
573590 }
574591
575592 /**
0 commit comments