]> source.dussan.org Git - nextcloud-server.git/commitdiff
External storage space is now not counted in total space
authorVincent Petry <pvince81@owncloud.com>
Mon, 18 Nov 2013 16:29:30 +0000 (17:29 +0100)
committerVincent Petry <pvince81@owncloud.com>
Mon, 18 Nov 2013 17:09:01 +0000 (18:09 +0100)
Added argument to getFileInfo() to disable adding the size of
mountpoints to a directory's size.

Fixes #5924

lib/private/files.php
lib/private/files/filesystem.php
lib/private/files/view.php
lib/private/helper.php
tests/lib/files/view.php

index c705d2adb1a20f7c0dcbc09871792a0b9a093b6f..8b4d5c59aee0cb8595eb3255b10e9348cef373e8 100644 (file)
@@ -28,8 +28,8 @@
 class OC_Files {
        static $tmpFiles = array();
 
-       static public function getFileInfo($path){
-               return \OC\Files\Filesystem::getFileInfo($path);
+       static public function getFileInfo($path, $includeMountPoints = true){
+               return \OC\Files\Filesystem::getFileInfo($path, $includeMountPoints);
        }
 
        static public function getDirectoryContent($path){
index 8500b3c581b3cad0cff8696a394855c8a8fcb1a9..a83e9aa86d24b8ccc8fe714539e741fbaf1bcd44 100644 (file)
@@ -725,6 +725,8 @@ class Filesystem {
         * get the filesystem info
         *
         * @param string $path
+        * @param boolean $includeMountPoints whether to add mountpoint sizes,
+        * defaults to true
         * @return array
         *
         * returns an associative array with the following keys:
@@ -734,8 +736,8 @@ class Filesystem {
         * - encrypted
         * - versioned
         */
-       public static function getFileInfo($path) {
-               return self::$defaultInstance->getFileInfo($path);
+       public static function getFileInfo($path, $includeMountPoints = true) {
+               return self::$defaultInstance->getFileInfo($path, $includeMountPoints);
        }
 
        /**
index c0b9f0fc9c8d5e8149b8c69d683d8f2ce64815a7..8cb56ede91b91734afbe82274f008c55fe3b59af 100644 (file)
@@ -762,6 +762,8 @@ class View {
         * get the filesystem info
         *
         * @param string $path
+        * @param boolean $includeMountPoints whether to add mountpoint sizes,
+        * defaults to true
         * @return array
         *
         * returns an associative array with the following keys:
@@ -771,7 +773,7 @@ class View {
         * - encrypted
         * - versioned
         */
-       public function getFileInfo($path) {
+       public function getFileInfo($path, $includeMountPoints = true) {
                $data = array();
                if (!Filesystem::isValidPath($path)) {
                        return $data;
@@ -798,7 +800,7 @@ class View {
                        $data = $cache->get($internalPath);
 
                        if ($data and $data['fileid']) {
-                               if ($data['mimetype'] === 'httpd/unix-directory') {
+                               if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') {
                                        //add the sizes of other mountpoints to the folder
                                        $mountPoints = Filesystem::getMountPoints($path);
                                        foreach ($mountPoints as $mountPoint) {
index 48031c1467f73d5bf1b379b2c89e8b86d2633cd2..c82d3bd4ef4ab1d513a7ca83e0986b49bd9023f8 100644 (file)
@@ -876,7 +876,8 @@ class OC_Helper {
         * @return array
         */
        public static function getStorageInfo($path) {
-               $rootInfo = \OC\Files\Filesystem::getFileInfo($path);
+               // return storage info without adding mount points
+               $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false);
                $used = $rootInfo['size'];
                if ($used < 0) {
                        $used = 0;
index 0cc86d6651a5029a0ebaf92fda5082e32a14620a..f358c15dd501c8c5e88e2f9e9f8997927df08401 100644 (file)
@@ -67,6 +67,11 @@ class View extends \PHPUnit_Framework_TestCase {
                $this->assertEquals($storageSize * 3, $cachedData['size']);
                $this->assertEquals('httpd/unix-directory', $cachedData['mimetype']);
 
+               // get cached data excluding mount points
+               $cachedData = $rootView->getFileInfo('/', false);
+               $this->assertEquals($storageSize, $cachedData['size']);
+               $this->assertEquals('httpd/unix-directory', $cachedData['mimetype']);
+
                $cachedData = $rootView->getFileInfo('/folder');
                $this->assertEquals($storageSize + $textSize, $cachedData['size']);
                $this->assertEquals('httpd/unix-directory', $cachedData['mimetype']);