diff --git a/lib/Sabre/Album/AlbumRoot.php b/lib/Sabre/Album/AlbumRoot.php index 0a10157b4..02a2ce323 100644 --- a/lib/Sabre/Album/AlbumRoot.php +++ b/lib/Sabre/Album/AlbumRoot.php @@ -156,13 +156,18 @@ public function getLastModified(): int { } public function copyInto($targetName, $sourcePath, INode $sourceNode): bool { - if ($sourceNode instanceof File) { - $sourceId = $sourceNode->getId(); - $ownerUID = $sourceNode->getFileInfo()->getOwner()->getUID(); - return $this->addFile($sourceId, $ownerUID); + if (!$sourceNode instanceof File) { + throw new Forbidden("The source is not a file"); } + + $sourceId = $sourceNode->getId(); + $ownerUID = $sourceNode->getFileInfo()->getOwner()->getUID(); $uid = $this->userId; - throw new \Exception("Can't add file to album, only files from $uid can be added"); + if ($ownerUID !== $uid) { + throw new Forbidden("Can't add file to album, only files from $uid can be added"); + } + + return $this->addFile($sourceId, $ownerUID); } protected function addFile(int $sourceId, string $ownerUID): bool {