From e84faa6fab9a5eac50ff49d2410a419460150936 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 25 Sep 2024 16:28:25 +0200 Subject: [PATCH] feat: Check upload directory share state Signed-off-by: Louis Chemineau --- lib/Sabre/Album/AlbumRoot.php | 5 ++++ src/components/PhotosPicker.vue | 49 ++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/lib/Sabre/Album/AlbumRoot.php b/lib/Sabre/Album/AlbumRoot.php index 00bcefd25..5b3e3fa5c 100644 --- a/lib/Sabre/Album/AlbumRoot.php +++ b/lib/Sabre/Album/AlbumRoot.php @@ -14,6 +14,7 @@ use OCA\Photos\Album\AlbumWithFiles; use OCA\Photos\Service\UserConfigService; use OCP\Files\Folder; +use OCP\Files\InvalidDirectoryException; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use Sabre\DAV\Exception\Conflict; @@ -91,6 +92,10 @@ public function createFile($name, $data = null) { throw new Conflict('The destination exists and is not a folder'); } + if ($photosFolder->isShared()) { + throw new InvalidDirectoryException('The destination is a received share'); + } + // Check for conflict and rename the file accordingly $newName = \basename(\OC_Helper::buildNotExistingFileName($photosLocation, $name)); diff --git a/src/components/PhotosPicker.vue b/src/components/PhotosPicker.vue index bb9ece02e..6c37c819b 100644 --- a/src/components/PhotosPicker.vue +++ b/src/components/PhotosPicker.vue @@ -43,18 +43,25 @@ import { UploadPicker } from '@nextcloud/upload' -import { NcButton, NcDialog, NcLoadingIcon, NcSelect, useIsMobile } from '@nextcloud/vue' +import { NcButton, NcDialog, NcLoadingIcon, NcSelect, NcNoteCard, useIsMobile } from '@nextcloud/vue' import { defineComponent } from 'vue' import { mapGetters } from 'vuex' import moment from '@nextcloud/moment' +import { getCurrentUser } from '@nextcloud/auth' import ImagePlus from 'vue-material-design-icons/ImagePlus.vue' @@ -116,6 +124,7 @@ export default defineComponent({ NcDialog, NcLoadingIcon, NcSelect, + NcNoteCard, UploadPicker, }, @@ -176,6 +185,7 @@ export default defineComponent({ uploadContext: { route: 'albumpicker', }, + currentUser: getCurrentUser(), } }, @@ -280,5 +290,18 @@ export default defineComponent({ justify-content: center; } } + + &__actions { + display: flex; + flex-direction: column; + flex-grow: 1; + + &__buttons { + display: flex; + align-items: center; + justify-content: end; + gap: 16px; + } + } }