diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-11-06 11:57:04 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-11-21 12:04:54 +0100 |
commit | 356eef07398f8829a2558eee809599be60441b59 (patch) | |
tree | 29ff768c8b73af5f73d75610dedbf4c6231bb28a /lib | |
parent | 391f267d380f0d098d730d3bc74633192cc13570 (diff) | |
download | nextcloud-server-356eef07398f8829a2558eee809599be60441b59.tar.gz nextcloud-server-356eef07398f8829a2558eee809599be60441b59.zip |
Quota storage wrapper is now used for all users in sharing mode
When accessing a shared folder, the folder's owner appears as mountpoint
but wasn't wrapped by a quota storage wrapper.
This fix makes sure that all home storages are wrapped by a quota
storage wrapper, if applicable, to make sure quotas are respected when
uploading into shared folders.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/private/util.php | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/private/util.php b/lib/private/util.php index 176eb4bc369..88f1f197b5d 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -53,16 +53,31 @@ 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 . '/'){ - return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota)); - } else { - return $storage; + \OC\Files\Filesystem::addStorageWrapper(function($mountPoint, $storage){ + // set up quota for home storages, even for other users + // which can happen when using sharing + + if (strlen($mountPoint) > 1) { + // the user name will be extracted from the mountpoint + // with the format '/username/' (no suffix) + $user = null; + // find second separator + $nextSepPos = strpos($mountPoint, '/', 1); + // next separator is the last one, format matches + if ($nextSepPos === strlen($mountPoint) - 1) { + $user = substr($mountPoint, 1, $nextSepPos - 1); } - }); - } + if ($user) { + $quota = OC_Util::getUserQuota($user); + if ($quota !== \OC\Files\SPACE_UNLIMITED) { + return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota)); + } + } + } + + return $storage; + }); + $userDir = '/'.$user.'/files'; $userRoot = OC_User::getHome($user); $userDirectory = $userRoot . '/files'; |