[Pkg-owncloud-commits] [owncloud] 64/457: Catch NotFoundException and return no quota information which simply reflects the current state - no file storage has been initialized for the user.

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:05:26 UTC 2015


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

taffit pushed a commit to branch stable8
in repository owncloud.

commit 6d97dfb00c6bd660d9f8ac3a579f34d70fe87af1
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Tue May 19 12:38:03 2015 +0200

    Catch NotFoundException and return no quota information which simply reflects the current state - no file storage has been initialized for the user.
---
 apps/provisioning_api/lib/users.php | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php
index 43cf22b..b709e09 100644
--- a/apps/provisioning_api/lib/users.php
+++ b/apps/provisioning_api/lib/users.php
@@ -27,6 +27,7 @@ use \OC_SubAdmin;
 use \OC_User;
 use \OC_Group;
 use \OC_Helper;
+use OCP\Files\NotFoundException;
 
 class Users {
 
@@ -92,16 +93,8 @@ class Users {
 		$config = \OC::$server->getConfig();
 
 		// Find the data
-		$data = array();
-		\OC_Util::tearDownFS();
-		\OC_Util::setupFS($userId);
-		$storage = OC_Helper::getStorageInfo('/');
-		$data['quota'] = array(
-			'free' =>  $storage['free'],
-			'used' =>  $storage['used'],
-			'total' =>  $storage['total'],
-			'relative' => $storage['relative'],
-			);
+		$data = [];
+		$data = self::fillStorageInfo($userId, $data);
 		$data['enabled'] = $config->getUserValue($userId, 'core', 'enabled', 'true');
 		$data['email'] = $config->getUserValue($userId, 'settings', 'email');
 		$data['displayname'] = OC_User::getDisplayName($parameters['userid']);
@@ -350,4 +343,27 @@ class Users {
 			return new OC_OCS_Result($groups);
 		}
 	}
+
+	/**
+	 * @param $userId
+	 * @param $data
+	 * @return mixed
+	 * @throws \OCP\Files\NotFoundException
+	 */
+	private static function fillStorageInfo($userId, $data) {
+		try {
+			\OC_Util::tearDownFS();
+			\OC_Util::setupFS($userId);
+			$storage = OC_Helper::getStorageInfo('/');
+			$data['quota'] = [
+				'free' => $storage['free'],
+				'used' => $storage['used'],
+				'total' => $storage['total'],
+				'relative' => $storage['relative'],
+			];
+		} catch (NotFoundException $ex) {
+			$data['quota'] = [];
+		}
+		return $data;
+	}
 }

-- 
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