fix(FilesDropPlugin): Disable plugin for chunked uploads

Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
provokateurin 2025-10-15 23:22:40 +02:00
parent 0320a99ccc
commit f4f0a1a94b
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View file

@ -42,6 +42,10 @@ class FilesDropPlugin extends ServerPlugin {
}
public function onMkcol(RequestInterface $request, ResponseInterface $response) {
if ($this->isChunkedUpload($request)) {
return;
}
if (!$this->enabled || $this->share === null) {
return;
}
@ -58,7 +62,15 @@ class FilesDropPlugin extends ServerPlugin {
return false;
}
private function isChunkedUpload(RequestInterface $request): bool {
return str_starts_with(substr($request->getUrl(), strlen($request->getBaseUrl()) - 1), '/uploads/');
}
public function beforeMethod(RequestInterface $request, ResponseInterface $response) {
if ($this->isChunkedUpload($request)) {
return;
}
if (!$this->enabled || $this->share === null) {
return;
}

View file

@ -56,13 +56,6 @@ class FilesDropPluginTest extends TestCase {
->willReturn('token');
}
public function testNotEnabled(): void {
$this->request->expects($this->never())
->method($this->anything());
$this->plugin->beforeMethod($this->request, $this->response);
}
public function testValid(): void {
$this->plugin->enable();
$this->plugin->setShare($this->share);