From 52da5f715f0be61ba82eccdbc9434abc7fce3e66 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 20 Aug 2024 13:31:35 +0200 Subject: [PATCH 1/2] feat: store the mountpoint of storages in the mount options Signed-off-by: Robin Appelman --- lib/private/Files/SetupManager.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index 511e80bd7d9..9e5ecbbc870 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -120,8 +120,9 @@ class SetupManager { $prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false); Filesystem::addStorageWrapper('mount_options', function ($mountPoint, IStorage $storage, IMountPoint $mount) { - if ($mount->getOptions() && $storage->instanceOfStorage(Common::class)) { - $storage->setMountOptions($mount->getOptions()); + if ($storage->instanceOfStorage(Common::class)) { + $options = array_merge($mount->getOptions(), ['mount_point' => $mountPoint]); + $storage->setMountOptions($options); } return $storage; }); From c2af3e04b0c1fb1aba8d7087649a86aa3524211e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 20 Aug 2024 13:32:03 +0200 Subject: [PATCH 2/2] fix: use mountpoint from storage to find the encryption keys Signed-off-by: Robin Appelman --- lib/private/Files/Storage/Wrapper/Encryption.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 499ba1f317f..c549e3a439a 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -44,6 +44,7 @@ use OC\Files\Cache\CacheEntry; use OC\Files\Filesystem; use OC\Files\Mount\Manager; use OC\Files\ObjectStore\ObjectStoreStorage; +use OC\Files\Storage\Common; use OC\Files\Storage\LocalTempFileTrait; use OC\Memcache\ArrayCache; use OCP\Cache\CappedMemoryCache; @@ -806,9 +807,8 @@ class Encryption extends Wrapper { // first copy the keys that we reuse the existing file key on the target location // and don't create a new one which would break versions for example. - $mount = $this->mountManager->findByStorageId($sourceStorage->getId()); - if (count($mount) >= 1) { - $mountPoint = $mount[0]->getMountPoint(); + if ($sourceStorage->instanceOfStorage(Common::class) && $sourceStorage->getMountOption('mount_point')) { + $mountPoint = $sourceStorage->getMountOption('mount_point'); $source = $mountPoint . '/' . $sourceInternalPath; $target = $this->getFullPath($targetInternalPath); $this->copyKeys($source, $target);