Skip to content

Commit 98086ee

Browse files
committed
SymlinkPlugin: Fix update of symlinks for move operation
Signed-off-by: Tamino Bauknecht <dev@tb6.eu>
1 parent 0d600c5 commit 98086ee

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

apps/dav/lib/Upload/SymlinkPlugin.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,31 @@ public function httpDelete(RequestInterface $request, ResponseInterface $respons
112112
}
113113

114114
public function afterMove(string $source, string $destination) {
115-
$sourceNode = $this->server->tree->getNodeForPath($source);
115+
// source node does not exist anymore, thus use still existing parent
116+
$sourceParentNode = dirname($source);
117+
$sourceParentNode = $this->server->tree->getNodeForPath($sourceParentNode);
118+
if (!$sourceParentNode instanceof \OCA\DAV\Connector\Sabre\Node) {
119+
throw new \Sabre\DAV\Exception\NotImplemented('Unable to check if moved file is a symlink!');
120+
}
116121
$destinationNode = $this->server->tree->getNodeForPath($destination);
117-
if ($this->symlinkManager->isSymlink($sourceNode)) {
118-
$this->symlinkManager->deleteSymlink($sourceNode);
119-
$this->symlinkManager->storeSymlink($destinationNode);
120-
} elseif ($this->symlinkManager->isSymlink($destinationNode)) {
122+
if (!$destinationNode instanceof \OCA\DAV\Connector\Sabre\Node) {
123+
throw new \Sabre\DAV\Exception\NotImplemented('Unable to set symlink information on move destination!');
124+
}
125+
126+
$sourceInfo = new \OC\Files\FileInfo(
127+
$source,
128+
$sourceParentNode->getFileInfo()->getStorage(),
129+
$sourceParentNode->getInternalPath() . '/' . basename($source),
130+
[],
131+
$sourceParentNode->getFileInfo()->getMountPoint());
132+
$destinationInfo = $destinationNode->getFileInfo();
133+
134+
if ($this->symlinkManager->isSymlink($sourceInfo)) {
135+
$this->symlinkManager->deleteSymlink($sourceInfo);
136+
$this->symlinkManager->storeSymlink($destinationInfo);
137+
} elseif ($this->symlinkManager->isSymlink($destinationInfo)) {
121138
// source was not a symlink, but destination was a symlink before
122-
$this->symlinkManager->deleteSymlink($destinationNode);
139+
$this->symlinkManager->deleteSymlink($destinationInfo);
123140
}
124141
}
125142
}

0 commit comments

Comments
 (0)