Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions lib/Sabre/Album/AlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down