new exception

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2020-02-21 11:12:24 +01:00
committed by Julius Härtl
parent 7750621917
commit 1e3ff41cb2
4 changed files with 48 additions and 13 deletions

View File

@@ -42,6 +42,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\Deck\ConflictException;
class FileService implements IAttachmentService {
@@ -146,13 +147,14 @@ class FileService implements IAttachmentService {
* @param Attachment $attachment
* @throws NotPermittedException
* @throws StatusException
* @throws ConflictException
*/
public function create(Attachment $attachment) {
$file = $this->getUploadedFile();
$folder = $this->getFolder($attachment);
$fileName = $file['name'];
if ($folder->fileExists($fileName)) {
throw new StatusException('File already exists.');
throw new ConflictException('File already exists.');
}
$target = $folder->newFile($fileName);