From c5d594d6029665aa03b6d95d1c0b8a97b061b2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 17 Nov 2023 08:51:32 +0100 Subject: [PATCH 1/4] fix: Avoid conflicts on deck attachments folder name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/ConfigService.php | 8 ++++++++ lib/Service/FilesAppService.php | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 5aca2222c..48bf068c0 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -176,4 +176,12 @@ class ConfigService { 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 2ec7de929..f0d4a66e8 100644 --- a/lib/Service/FilesAppService.php +++ b/lib/Service/FilesAppService.php @@ -31,6 +31,7 @@ use OCA\Deck\Sharing\DeckShareProvider; 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; @@ -185,10 +186,20 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService { $userFolder = $this->rootFolder->getUserFolder($this->userId); try { $folder = $userFolder->get($this->configService->getAttachmentFolder()); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $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'); From fd0f37e9d68e16ce4e2ccfaac540e10ce349f1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 27 Mar 2024 16:01:51 +0100 Subject: [PATCH 2/4] ci: Update base query count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl From f3b704b56d19534fffc5e7c804e5a907531dd9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 28 Mar 2024 10:14:56 +0100 Subject: [PATCH 3/4] fix: Compatibility with php 7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/FilesAppService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/FilesAppService.php b/lib/Service/FilesAppService.php index f0d4a66e8..e214b7ca3 100644 --- a/lib/Service/FilesAppService.php +++ b/lib/Service/FilesAppService.php @@ -186,7 +186,7 @@ class FilesAppService implements IAttachmentService, ICustomAttachmentService { $userFolder = $this->rootFolder->getUserFolder($this->userId); try { $folder = $userFolder->get($this->configService->getAttachmentFolder()); - } catch (NotFoundException) { + } catch (NotFoundException $e) { $folder = $userFolder->newFolder($this->configService->getAttachmentFolder()); } From 2817d8bb431cabded8deab4bdd8256211521e7a4 Mon Sep 17 00:00:00 2001 From: Luka Trovic Date: Fri, 24 May 2024 13:28:48 +0200 Subject: [PATCH 4/4] ci: update php setup for integration check Signed-off-by: Luka Trovic --- .github/workflows/integration.yml | 2 +- .github/workflows/phpunit.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 95e6783d2..d53f5ccd5 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -72,7 +72,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} tools: phpunit - extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql, + extensions: mbstring, gd, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql, coverage: none - name: Set up PHPUnit diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 48c5ee220..04cda0056 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -62,7 +62,7 @@ jobs: path: apps/${{ env.APP_NAME }} - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@2.18.0 + uses: shivammathur/setup-php@2.15.0 with: php-version: ${{ matrix.php-versions }} tools: phpunit