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