Merge pull request #51845 from nextcloud/zip-download-no-sabre-response

fix: don't have sabre/dav send it's own reponse if we already send the zip response
This commit is contained in:
Ferdinand Thiessen 2025-04-01 19:26:04 +02:00 committed by GitHub
commit fdc0b1ecf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -55,6 +55,8 @@ class ZipFolderPlugin extends ServerPlugin {
public function initialize(Server $server): void {
$this->server = $server;
$this->server->on('method:GET', $this->handleDownload(...), 100);
// low priority to give any other afterMethod:* a chance to fire before we cancel everything
$this->server->on('afterMethod:GET', $this->afterDownload(...), 999);
}
/**
@ -172,4 +174,19 @@ class ZipFolderPlugin extends ServerPlugin {
$streamer->finalize();
return false;
}
/**
* Tell sabre/dav not to trigger it's own response sending logic as the handleDownload will have already send the response
*
* @return false|null
*/
public function afterDownload(Request $request, Response $response): ?bool {
$node = $this->tree->getNodeForPath($request->getPath());
if (!($node instanceof Directory)) {
// only handle directories
return null;
} else {
return false;
}
}
}