[Pkg-owncloud-commits] [owncloud] 20/83: External storage space is now not counted in total space

David Prévot taffit at moszumanska.debian.org
Wed Dec 18 13:05:25 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch 5.0
in repository owncloud.

commit 9ccaf85078da4efa28e5d4a7315459b1c8c68e9e
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Mon Nov 18 17:29:30 2013 +0100

    External storage space is now not counted in total space
    
    Added argument to getFileInfo() to disable adding the size of
    mountpoints to a directory's size.
    
    Backport of 614e4d485c8b74f6879c401f8cbb93e9335bf9b3
---
 lib/files.php            | 4 ++--
 lib/files/filesystem.php | 6 ++++--
 lib/files/view.php       | 6 ++++--
 lib/helper.php           | 3 ++-
 tests/lib/files/view.php | 5 +++++
 5 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/lib/files.php b/lib/files.php
index 04ba51d..b314edb 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -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){
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 1850d50..95bdd10 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -624,6 +624,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:
@@ -633,8 +635,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);
 	}
 
 	/**
diff --git a/lib/files/view.php b/lib/files/view.php
index f02e3d4..fd408fe 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -750,6 +750,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:
@@ -759,7 +761,7 @@ class View {
 	 * - encrypted
 	 * - versioned
 	 */
-	public function getFileInfo($path) {
+	public function getFileInfo($path, $includeMountPoints = true) {
 		$data = array();
 		if (!Filesystem::isValidPath($path)) {
 			return $data;
@@ -786,7 +788,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) {
diff --git a/lib/helper.php b/lib/helper.php
index 819b1e8..71b3bd5 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -831,7 +831,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;
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 732f61d..b1edb73 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -57,6 +57,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']);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list