|
46 | 46 | use OCP\Lock\ILockingProvider; |
47 | 47 | use Sabre\DAV\Exception\BadRequest; |
48 | 48 | use Sabre\DAV\Exception\InsufficientStorage; |
| 49 | +use Sabre\DAV\Exception\MethodNotAllowed; |
49 | 50 | use Sabre\DAV\Exception\NotFound; |
50 | 51 | use Sabre\DAV\Exception\PreconditionFailed; |
51 | 52 | use Sabre\DAV\ICollection; |
@@ -84,14 +85,24 @@ public function __construct(ICacheFactory $cacheFactory) { |
84 | 85 | * @inheritdoc |
85 | 86 | */ |
86 | 87 | public function initialize(Server $server) { |
87 | | - $server->on('afterMethod:MKCOL', [$this, 'afterMkcol']); |
| 88 | + $server->on('beforeMethod:GET', [$this, 'beforeGet']); |
88 | 89 | $server->on('beforeMethod:PUT', [$this, 'beforePut']); |
89 | 90 | $server->on('beforeMethod:DELETE', [$this, 'beforeDelete']); |
90 | 91 | $server->on('beforeMove', [$this, 'beforeMove'], 90); |
| 92 | + $server->on('afterMethod:MKCOL', [$this, 'afterMkcol']); |
91 | 93 |
|
92 | 94 | $this->server = $server; |
93 | 95 | } |
94 | 96 |
|
| 97 | + public function beforeGet(RequestInterface $request) { |
| 98 | + $sourceNode = $this->server->tree->getNodeForPath($request->getPath()); |
| 99 | + if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) { |
| 100 | + throw new MethodNotAllowed('Reading intermediate uploads is not allowed'); |
| 101 | + } |
| 102 | + |
| 103 | + return true; |
| 104 | + } |
| 105 | + |
95 | 106 | /** |
96 | 107 | * @param string $path |
97 | 108 | * @param bool $createIfNotExists |
|
0 commit comments