|
8 | 8 | use bantu\IniGetWrapper\IniGetWrapper; |
9 | 9 | use OC\Files\FilenameValidator; |
10 | 10 | use OC\Files\Filesystem; |
| 11 | +use OC\Files\ObjectStore\HomeObjectStoreStorage; |
11 | 12 | use OC\Files\Storage\Home; |
12 | 13 | use OC\Files\Storage\Wrapper\Quota; |
13 | 14 | use OC\SystemConfig; |
14 | 15 | use OCA\Files_Sharing\External\Storage; |
15 | 16 | use OCP\Files\FileInfo; |
16 | 17 | use OCP\Files\Mount\IMountPoint; |
17 | 18 | use OCP\Files\NotFoundException; |
| 19 | +use OCP\Files\Storage\ISharedStorage; |
18 | 20 | use OCP\IBinaryFinder; |
19 | 21 | use OCP\ICacheFactory; |
20 | 22 | use OCP\IConfig; |
@@ -190,24 +192,31 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin |
190 | 192 | self::$quotaIncludeExternalStorage = false; |
191 | 193 | } |
192 | 194 | if (self::$quotaIncludeExternalStorage) { |
193 | | - if ($storage->instanceOfStorage('\OC\Files\Storage\Home') |
| 195 | + if ($storage->instanceOfStorage(ISharedStorage::class)) { |
| 196 | + // we must use the shared nodes owner, |
| 197 | + // because if user A shared a file with user B and B shares this again, |
| 198 | + // then the share initiator is user B but the quota that this counts in is user A's quota. |
| 199 | + /** @var ISharedStorage $storage */ |
| 200 | + $user = $storage->getShare()->getNode()->getOwner(); |
| 201 | + } elseif ( |
| 202 | + $storage->instanceOfStorage('\OC\Files\Storage\Home') |
194 | 203 | || $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage') |
195 | 204 | ) { |
196 | | - /** @var Home $storage */ |
| 205 | + /** @var Home|HomeObjectStoreStorage $storage */ |
197 | 206 | $user = $storage->getUser(); |
198 | 207 | } else { |
199 | 208 | $user = Server::get(IUserSession::class)->getUser(); |
200 | 209 | } |
201 | 210 | $quota = $user?->getQuotaBytes() ?? FileInfo::SPACE_UNKNOWN; |
202 | | - if ($quota !== FileInfo::SPACE_UNLIMITED) { |
| 211 | + if ($user !== null && $quota !== FileInfo::SPACE_UNLIMITED) { |
203 | 212 | // always get free space / total space from root + mount points |
204 | 213 | return self::getGlobalStorageInfo($quota, $user, $mount); |
205 | 214 | } |
206 | 215 | } |
207 | 216 |
|
208 | 217 | // TODO: need a better way to get total space from storage |
209 | 218 | if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')) { |
210 | | - /** @var Quota $storage */ |
| 219 | + /** @var Quota $sourceStorage */ |
211 | 220 | $quota = $sourceStorage->getQuota(); |
212 | 221 | } |
213 | 222 | try { |
|
0 commit comments