]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow reusing FileInfo for getStorageInfo
authorRobin Appelman <icewind@owncloud.com>
Wed, 2 Apr 2014 15:10:57 +0000 (17:10 +0200)
committerRobin Appelman <icewind@owncloud.com>
Wed, 2 Apr 2014 15:10:57 +0000 (17:10 +0200)
apps/files/index.php
lib/private/helper.php

index 4d765b69e4126b67262cfefae868e6f7e753535c..f2c5bd13359b36a3de721f805ec68bb89637bf67 100644 (file)
@@ -38,7 +38,7 @@ OCP\App::setActiveNavigationEntry('files_index');
 // Load the files
 $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
 $dir = \OC\Files\Filesystem::normalizePath($dir);
-$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
+$dirInfo = \OC\Files\Filesystem::getFileInfo($dir, false);
 // Redirect if directory does not exist
 if (!$dirInfo || !$dirInfo->getType() === 'dir') {
        header('Location: ' . OCP\Util::getScriptName() . '');
@@ -94,7 +94,7 @@ $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir
 $permissions = $dirInfo->getPermissions();
 
 // information about storage capacities
-$storageInfo=OC_Helper::getStorageInfo($dir);
+$storageInfo=OC_Helper::getStorageInfo($dir, $dirInfo);
 $freeSpace=$storageInfo['free'];
 $uploadLimit=OCP\Util::uploadLimit();
 $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
index d7ac0b5f4fa64846adad31d58c9c6ed960a3653d..da3d3cd1c6ea55f0042f9e14adafcee55a851281 100644 (file)
@@ -875,12 +875,15 @@ class OC_Helper {
         * Calculate the disc space for the given path
         *
         * @param string $path
+        * @param \OCP\Files\FileInfo $rootInfo (optional)
         * @return array
         */
-       public static function getStorageInfo($path) {
+       public static function getStorageInfo($path, $rootInfo = null) {
                // return storage info without adding mount points
-               $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
-               $used = $rootInfo['size'];
+               if (is_null($rootInfo)) {
+                       $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
+               }
+               $used = $rootInfo->getSize();
                if ($used < 0) {
                        $used = 0;
                }