diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-11-21 06:59:50 -0800 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-11-21 06:59:50 -0800 |
commit | d0265f3388b43e05c40938142dd4b17abbf1dfc8 (patch) | |
tree | d97e53084ca611498efafaa3627bd37e0447257f /lib | |
parent | 3e1ade4397717ccf45d0916def6559ceb921f8f3 (diff) | |
parent | 69e8e7dbd5039652cceb078025248c308ffd0d55 (diff) | |
download | nextcloud-server-d0265f3388b43e05c40938142dd4b17abbf1dfc8.tar.gz nextcloud-server-d0265f3388b43e05c40938142dd4b17abbf1dfc8.zip |
Merge pull request #5715 from owncloud/quota-sharing-wrapotherusershome
Quota storage wrapper is now used for all users in sharing mode
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/storage/home.php | 17 | ||||
-rwxr-xr-x | lib/private/util.php | 21 |
2 files changed, 30 insertions, 8 deletions
diff --git a/lib/private/files/storage/home.php b/lib/private/files/storage/home.php index b4ceb8f4f9b..1c2a682f197 100644 --- a/lib/private/files/storage/home.php +++ b/lib/private/files/storage/home.php @@ -22,6 +22,12 @@ class Home extends Local { */ protected $user; + /** + * @brief Construct a Home storage instance + * @param array $arguments array with "user" containing the + * storage owner and "legacy" containing "true" if the storage is + * a legacy storage with "local::" URL instead of the new "home::" one. + */ public function __construct($arguments) { $this->user = $arguments['user']; $datadir = $this->user->getHome(); @@ -40,10 +46,21 @@ class Home extends Local { return $this->id; } + /** + * @return \OC\Files\Cache\HomeCache + */ public function getCache($path = '') { if (!isset($this->cache)) { $this->cache = new \OC\Files\Cache\HomeCache($this); } return $this->cache; } + + /** + * @brief Returns the owner of this home storage + * @return \OC\User\User owner of this home storage + */ + public function getUser() { + return $this->user; + } } diff --git a/lib/private/util.php b/lib/private/util.php index 176eb4bc369..959d36a89e9 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -53,16 +53,21 @@ class OC_Util { //if we aren't logged in, there is no use to set up the filesystem if( $user != "" ) { - $quota = self::getUserQuota($user); - if ($quota !== \OC\Files\SPACE_UNLIMITED) { - \OC\Files\Filesystem::addStorageWrapper(function($mountPoint, $storage) use ($quota, $user) { - if ($mountPoint === '/' . $user . '/'){ + \OC\Files\Filesystem::addStorageWrapper(function($mountPoint, $storage){ + // set up quota for home storages, even for other users + // which can happen when using sharing + + if ($storage instanceof \OC\Files\Storage\Home) { + $user = $storage->getUser()->getUID(); + $quota = OC_Util::getUserQuota($user); + if ($quota !== \OC\Files\SPACE_UNLIMITED) { return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota)); - } else { - return $storage; } - }); - } + } + + return $storage; + }); + $userDir = '/'.$user.'/files'; $userRoot = OC_User::getHome($user); $userDirectory = $userRoot . '/files'; |