diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-07-25 16:01:37 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-07-25 16:01:37 +0200 |
commit | e2f04b3b429b42975f4457b77ca720396506e512 (patch) | |
tree | 427a389d52b52c553cd6d8db5ab1f9f9db05dfc6 /lib/util.php | |
parent | 5209cff371c448a5fec75882044b7a8e3ed05f95 (diff) | |
download | nextcloud-server-e2f04b3b429b42975f4457b77ca720396506e512.tar.gz nextcloud-server-e2f04b3b429b42975f4457b77ca720396506e512.zip |
use storage wrapper for quota instead of a filesystem proxy
Diffstat (limited to 'lib/util.php')
-rwxr-xr-x | lib/util.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/util.php b/lib/util.php index 2586ad28320..4c878f8b2fe 100755 --- a/lib/util.php +++ b/lib/util.php @@ -46,6 +46,16 @@ class OC_Util { } if( $user != "" ) { //if we aren't logged in, there is no use to set up the filesystem + $quota = self::getUserQuota($user); + if ($quota !== \OC\Files\SPACE_UNLIMITED) { + \OC\Files\Filesystem::addStorageWrapper(function($mountPoint, $storage) use ($quota, $user) { + if ($mountPoint === '/' . $user . '/'){ + return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota)); + } else { + return $storage; + } + }); + } $user_dir = '/'.$user.'/files'; $user_root = OC_User::getHome($user); $userdirectory = $user_root . '/files'; @@ -55,9 +65,7 @@ class OC_Util { //jail the user into his "home" directory \OC\Files\Filesystem::init($user, $user_dir); - $quotaProxy=new OC_FileProxy_Quota(); $fileOperationProxy = new OC_FileProxy_FileOperations(); - OC_FileProxy::register($quotaProxy); OC_FileProxy::register($fileOperationProxy); OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir)); @@ -65,6 +73,18 @@ class OC_Util { return true; } + public static function getUserQuota($user){ + $userQuota = OC_Preferences::getValue($user, 'files', 'quota', 'default'); + if($userQuota === 'default') { + $userQuota = OC_AppConfig::getValue('files', 'default_quota', 'none'); + } + if($userQuota === 'none') { + return \OC\Files\SPACE_UNLIMITED; + }else{ + return OC_Helper::computerFileSize($userQuota); + } + } + public static function tearDownFS() { \OC\Files\Filesystem::tearDown(); self::$fsSetup=false; |