Skip to content

Commit

Permalink
Merge pull request #47354 from nextcloud/backport/47346/stable29
Browse files Browse the repository at this point in the history
[stable29] store the mountpoint of storages in the mount options and use it to find the encryption keys
  • Loading branch information
skjnldsv committed Aug 20, 2024
2 parents 1e93ebc + cf2826d commit 0a65af5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/private/Files/SetupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ private function setupBuiltinWrappers() {
$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;
});
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
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;
Expand Down Expand Up @@ -806,9 +807,8 @@ private function copyBetweenStorage(

// 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);
Expand Down

0 comments on commit 0a65af5

Please sign in to comment.