diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 72bbe803c..8f4e05620 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [14.x] + node-version: [16.x] # containers: [1, 2, 3] php-versions: [ '7.4' ] databases: [ 'sqlite' ] diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 8974010c6..c94355985 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -210,4 +210,12 @@ public function getAttachmentFolder(string $userId = null): string { return $this->config->getUserValue($userId ?? $this->getUserId(), 'deck', 'attachment_folder', '/Deck'); } + + public function setAttachmentFolder(?string $userId = null, string $path): void { + if ($userId === null && $this->getUserId() === null) { + throw new NoPermissionException('Must be logged in get the attachment folder'); + } + + $this->config->setUserValue($userId ?? $this->getUserId(), 'deck', 'attachment_folder', $path); + } } diff --git a/lib/Service/FilesAppService.php b/lib/Service/FilesAppService.php index 09e0c16da..9a46a4536 100644 --- a/lib/Service/FilesAppService.php +++ b/lib/Service/FilesAppService.php @@ -31,6 +31,7 @@ use OCA\Deck\StatusException; use OCP\AppFramework\Http\StreamResponse; use OCP\Constants; +use OCP\Files\Folder; use OCP\Files\IMimeTypeDetector; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; @@ -190,6 +191,16 @@ public function create(Attachment $attachment) { $folder = $userFolder->newFolder($this->configService->getAttachmentFolder()); } + if ($folder->isShared()) { + $folderName = $userFolder->getNonExistingName($this->configService->getAttachmentFolder()); + $folder = $userFolder->newFolder($folderName); + $this->configService->setAttachmentFolder($this->userId, $folderName); + } + + if (!$folder instanceof Folder || $folder->isShared()) { + throw new NotFoundException('No target folder found'); + } + $fileName = $folder->getNonExistingName($fileName); $target = $folder->newFile($fileName); $content = fopen($file['tmp_name'], 'rb'); diff --git a/tests/integration/base-query-count.txt b/tests/integration/base-query-count.txt index 4fe36e923..be3d2129f 100644 --- a/tests/integration/base-query-count.txt +++ b/tests/integration/base-query-count.txt @@ -1 +1 @@ -68024 +79470