Skip to content

Commit 24d5ee5

Browse files
committed
SymlinkPlugin/FilesPlugin: Fix httpGet and httpDelete for symlinks
1 parent 53749a4 commit 24d5ee5

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,14 @@ public function handleDownloadToken(RequestInterface $request, ResponseInterface
231231
public function httpGet(RequestInterface $request, ResponseInterface $response) {
232232
// only handle symlinks
233233
$node = $this->tree->getNodeForPath($request->getPath());
234-
if (!($node instanceof \OCP\Files\File && $this->symlinkManager->isSymlink($node))) {
234+
if (!($node instanceof \OCA\DAV\Connector\Sabre\File && $this->symlinkManager->isSymlink($node->getFileInfo()))) {
235235
return;
236236
}
237237

238-
$response->addHeader('OC-File-Type', '1');
239-
$response->setBody($node->getContent());
238+
$response->setHeader('OC-File-Type', '1');
239+
$response->setHeader('OC-ETag', $node->getEtag());
240+
$response->setBody($node->get());
241+
$response->setStatus(200);
240242
// do not continue processing this request
241243
return false;
242244
}

apps/dav/lib/Upload/SymlinkPlugin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,16 @@ public function httpPut(RequestInterface $request, ResponseInterface $response):
7878

7979
public function httpDelete(RequestInterface $request, ResponseInterface $response): bool {
8080
$path = $request->getPath();
81-
$node = $this->server->tree->getNodeForPath(dirname($path));
82-
if (!$node instanceof \OCA\DAV\Connector\Sabre\File) {
81+
$node = $this->server->tree->getNodeForPath($path);
82+
if (!$node instanceof \OCA\DAV\Connector\Sabre\Node) {
8383
return true;
8484
}
8585
$info = $node->getFileInfo();
8686
if ($this->symlinkManager->isSymlink($info)) {
87-
$this->symlinkManager->deleteSymlink($info);
87+
if (!$this->symlinkManager->deleteSymlink($info)) {
88+
$symlinkName = $info->getName();
89+
throw new \Sabre\DAV\Exception\NotFound("Unable to delete symlink '$symlinkName'!");
90+
}
8891
}
8992
// always propagate to trigger deletion of regular file representing symlink in filesystem
9093
return true;

0 commit comments

Comments
 (0)