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