diff options
Diffstat (limited to 'apps/dav/lib/Upload/ChunkingPlugin.php')
-rw-r--r-- | apps/dav/lib/Upload/ChunkingPlugin.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php index 35487f61429..5a8d762de80 100644 --- a/apps/dav/lib/Upload/ChunkingPlugin.php +++ b/apps/dav/lib/Upload/ChunkingPlugin.php @@ -23,7 +23,10 @@ namespace OCA\DAV\Upload; +use OCA\DAV\Connector\Sabre\Directory; use Sabre\DAV\Exception\BadRequest; +use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\INode; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; @@ -45,6 +48,9 @@ class ChunkingPlugin extends ServerPlugin { /** * @param string $sourcePath source path * @param string $destination destination path + * @return bool|void + * @throws BadRequest + * @throws NotFound */ public function beforeMove($sourcePath, $destination) { $this->sourceNode = $this->server->tree->getNodeForPath($sourcePath); @@ -53,6 +59,16 @@ class ChunkingPlugin extends ServerPlugin { return; } + try { + /** @var INode $destinationNode */ + $destinationNode = $this->server->tree->getNodeForPath($destination); + if ($destinationNode instanceof Directory) { + throw new BadRequest("The given destination $destination is a directory."); + } + } catch (NotFound $e) { + // If the destination does not exist yet it's not a directory either ;) + } + $this->verifySize(); return $this->performMove($sourcePath, $destination); } |