|
29 | 29 | use OCP\Lock\ILockingProvider; |
30 | 30 | use Sabre\DAV\Exception\BadRequest; |
31 | 31 | use Sabre\DAV\Exception\InsufficientStorage; |
| 32 | +use Sabre\DAV\Exception\MethodNotAllowed; |
32 | 33 | use Sabre\DAV\Exception\NotFound; |
33 | 34 | use Sabre\DAV\Exception\PreconditionFailed; |
34 | 35 | use Sabre\DAV\ICollection; |
@@ -67,14 +68,24 @@ public function __construct(ICacheFactory $cacheFactory) { |
67 | 68 | * @inheritdoc |
68 | 69 | */ |
69 | 70 | public function initialize(Server $server) { |
70 | | - $server->on('afterMethod:MKCOL', [$this, 'afterMkcol']); |
| 71 | + $server->on('beforeMethod:GET', $this->beforeGet(...)); |
71 | 72 | $server->on('beforeMethod:PUT', [$this, 'beforePut']); |
72 | 73 | $server->on('beforeMethod:DELETE', [$this, 'beforeDelete']); |
73 | 74 | $server->on('beforeMove', [$this, 'beforeMove'], 90); |
| 75 | + $server->on('afterMethod:MKCOL', [$this, 'afterMkcol']); |
74 | 76 |
|
75 | 77 | $this->server = $server; |
76 | 78 | } |
77 | 79 |
|
| 80 | + protected function beforeGet(RequestInterface $request) { |
| 81 | + $sourceNode = $this->server->tree->getNodeForPath($request->getPath()); |
| 82 | + if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) { |
| 83 | + throw new MethodNotAllowed('Reading intermediate uploads is not allowed'); |
| 84 | + } |
| 85 | + |
| 86 | + return true; |
| 87 | + } |
| 88 | + |
78 | 89 | /** |
79 | 90 | * @param string $path |
80 | 91 | * @param bool $createIfNotExists |
|
0 commit comments