mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
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:
commit
fdc0b1ecf4
1 changed files with 17 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue