Skip to content

Commit d297e8f

Browse files
Merge pull request #51850 from nextcloud/backport/51845/stable31
[stable31] fix: don't have sabre/dav send it's own reponse if we already send the zip response
2 parents 3afd719 + 17569de commit d297e8f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

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)