Skip to content

Commit fdc0b1e

Browse files
authored
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
2 parents 29a4962 + 2b0116f commit fdc0b1e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public function __construct(
5555
public function initialize(Server $server): void {
5656
$this->server = $server;
5757
$this->server->on('method:GET', $this->handleDownload(...), 100);
58+
// low priority to give any other afterMethod:* a chance to fire before we cancel everything
59+
$this->server->on('afterMethod:GET', $this->afterDownload(...), 999);
5860
}
5961

6062
/**
@@ -172,4 +174,19 @@ public function handleDownload(Request $request, Response $response): ?bool {
172174
$streamer->finalize();
173175
return false;
174176
}
177+
178+
/**
179+
* Tell sabre/dav not to trigger it's own response sending logic as the handleDownload will have already send the response
180+
*
181+
* @return false|null
182+
*/
183+
public function afterDownload(Request $request, Response $response): ?bool {
184+
$node = $this->tree->getNodeForPath($request->getPath());
185+
if (!($node instanceof Directory)) {
186+
// only handle directories
187+
return null;
188+
} else {
189+
return false;
190+
}
191+
}
175192
}

0 commit comments

Comments
 (0)