diff options
author | icewind1991 <icewind1991@gmail.com> | 2013-08-19 03:38:55 -0700 |
---|---|---|
committer | icewind1991 <icewind1991@gmail.com> | 2013-08-19 03:38:55 -0700 |
commit | d7dde3cfbcb779f831130bdc65c8570437c73a71 (patch) | |
tree | 452ae55efd45a908f7f13b975438696ddbe4f4cf /lib/util.php | |
parent | a1d5aba5fd3795a6ee4a87c96abf0d35d3f8116d (diff) | |
parent | d8c71ba734d95e954d4ff3af50a44b94f9f016ff (diff) | |
download | nextcloud-server-d7dde3cfbcb779f831130bdc65c8570437c73a71.tar.gz nextcloud-server-d7dde3cfbcb779f831130bdc65c8570437c73a71.zip |
Merge pull request #4467 from owncloud/storage-wrapper-quota
Move quota logic from filesystem proxy to storage wrapper
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 d1752ecba0a..e03667b0794 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; |