|
55 | 55 | use OCP\IUserManager;
|
56 | 56 | use OCP\Lock\ILockingProvider;
|
57 | 57 | use OCP\Share\IShare;
|
| 58 | +use Psr\Log\LoggerInterface; |
58 | 59 |
|
59 | 60 | /**
|
60 | 61 | * Convert target path to source path and pass the function call to the correct storage provider
|
61 | 62 | */
|
62 | 63 | class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage, IDisableEncryptionStorage {
|
| 64 | + /** |
| 65 | + * @psalm-suppress NonInvariantDocblockPropertyType |
| 66 | + * @var \OC\Files\Storage\Storage|null $storage |
| 67 | + */ |
| 68 | + protected $storage; |
63 | 69 |
|
64 | 70 | /** @var \OCP\Share\IShare */
|
65 | 71 | private $superShare;
|
@@ -200,7 +206,17 @@ public function instanceOfStorage($class): bool {
|
200 | 206 | ])) {
|
201 | 207 | return false;
|
202 | 208 | }
|
203 |
| - return parent::instanceOfStorage($class); |
| 209 | + if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') { |
| 210 | + // FIXME Temporary fix to keep existing checks working |
| 211 | + return true; |
| 212 | + } |
| 213 | + if (is_a($this, $class)) { |
| 214 | + return true; |
| 215 | + } |
| 216 | + |
| 217 | + $storage = $this->getWrapperStorage(); |
| 218 | + |
| 219 | + return $storage->instanceOfStorage($class); |
204 | 220 | }
|
205 | 221 |
|
206 | 222 | /**
|
@@ -532,6 +548,16 @@ public function getSourceStorage() {
|
532 | 548 |
|
533 | 549 | public function getWrapperStorage() {
|
534 | 550 | $this->init();
|
| 551 | + |
| 552 | + // `init` should handle this, but apparently it sometimes doesn't |
| 553 | + if (!$this->storage instanceof IStorage) { |
| 554 | + $e = new \Exception('Share source storage is null after initializing for share: ' . $this->getShare()->getId()); |
| 555 | + $this->storage = new FailedStorage(['exception' => $e]); |
| 556 | + $this->cache = new FailedCache(); |
| 557 | + $this->rootPath = ''; |
| 558 | + $this->logger->logException($e); |
| 559 | + } |
| 560 | + |
535 | 561 | return $this->storage;
|
536 | 562 | }
|
537 | 563 |
|
|
0 commit comments