Skip to content

Commit 34aa2ee

Browse files
committed
Album upload
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent b076960 commit 34aa2ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Sabre/Album/AlbumRoot.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Sabre\DAV\ICollection;
3838
use Sabre\DAV\ICopyTarget;
3939
use Sabre\DAV\INode;
40+
use OCP\Files\NotPermittedException;
4041

4142
class AlbumRoot implements ICollection, ICopyTarget {
4243
private AlbumMapper $albumMapper;
@@ -88,11 +89,16 @@ public function setName($name) {
8889
public function createFile($name, $data = null) {
8990
try {
9091
$photosLocation = $this->userConfigService->getUserConfig('photosLocation');
92+
9193
$photosFolder = $this->userFolder->get($photosLocation);
94+
if (!($photosFolder instanceof Folder)) {
95+
throw new Conflict('The destination exists and is not a folder');
96+
}
97+
9298
$node = $photosFolder->newFile($name, $data);
9399
return $this->addFile($node->getId(), $node->getOwner()->getUID());
94100
} catch (\Exception $e) {
95-
throw new \Exception('The file could not be created');
101+
throw new Forbidden('Could not create file');
96102
}
97103
}
98104

@@ -150,6 +156,7 @@ private function addFile(int $sourceId, string $ownerUID): bool {
150156
$this->albumMapper->addFile($this->album->getAlbum()->getId(), $sourceId);
151157
return true;
152158
}
159+
return false;
153160
}
154161

155162
public function getAlbum(): AlbumWithFiles {

0 commit comments

Comments
 (0)