From 3f44d4a2a9996b2e0554464944ba3a7d66e0fcff Mon Sep 17 00:00:00 2001
From: Joas Schilling <coding@schilljs.com>
Date: Tue, 17 Oct 2023 15:22:21 +0200
Subject: [PATCH] fix(external): Get storage before update it

Signed-off-by: Joas Schilling <coding@schilljs.com>
---
 apps/files_external/lib/Service/UserStoragesService.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/apps/files_external/lib/Service/UserStoragesService.php b/apps/files_external/lib/Service/UserStoragesService.php
index c4e5fef400514..df6444e3a931b 100644
--- a/apps/files_external/lib/Service/UserStoragesService.php
+++ b/apps/files_external/lib/Service/UserStoragesService.php
@@ -124,6 +124,9 @@ public function addStorage(StorageConfig $newStorage) {
 	 * @throws NotFoundException if the given storage does not exist in the config
 	 */
 	public function updateStorage(StorageConfig $updatedStorage) {
+		// verify ownership through $this->isApplicable() and otherwise throws an exception
+		$this->getStorage($updatedStorage->getId());
+
 		$updatedStorage->setApplicableUsers([$this->getUser()->getUID()]);
 		return parent::updateStorage($updatedStorage);
 	}