Skip to content

Commit d03604a

Browse files
committed
fix(zip): suppress sabre/dav response if stream was actually sent
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent bb1ad1c commit d03604a

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class ZipFolderPlugin extends ServerPlugin {
3838
*/
3939
private ?Server $server = null;
4040

41+
/**
42+
* Whether handleDownload has fully streamed an archive for the current request.
43+
* Used by afterDownload to decide whether to suppress sabre/dav's own response logic.
44+
*/
45+
private bool $streamed = false;
46+
4147
public function __construct(
4248
private Tree $tree,
4349
private LoggerInterface $logger,
@@ -180,6 +186,8 @@ public function handleDownload(Request $request, Response $response): ?false {
180186
$this->streamNode($streamer, $node, $rootPath);
181187
}
182188
$streamer->finalize();
189+
$this->streamed = true; // archive fully streamed
190+
183191
return false;
184192
}
185193

@@ -190,12 +198,11 @@ public function afterDownload(Request $request, Response $response): ?false {
190198
if ($request->getHeader('X-Sabre-Original-Method') === 'HEAD') {
191199
return null;
192200
}
193-
$node = $this->tree->getNodeForPath($request->getPath());
194-
if (!($node instanceof Directory)) {
195-
// only handle directories
201+
202+
if (!$this->streamed) {
196203
return null;
197-
} else {
198-
return false;
199204
}
205+
206+
return false;
200207
}
201208
}

0 commit comments

Comments
 (0)