File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 3737use Sabre \DAV \ICollection ;
3838use Sabre \DAV \ICopyTarget ;
3939use Sabre \DAV \INode ;
40+ use OCP \Files \NotPermittedException ;
4041
4142class 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 {
You can’t perform that action at this time.
0 commit comments