diff --git a/lib/Mount/GroupFolderEncryptionJail.php b/lib/Mount/GroupFolderEncryptionJail.php new file mode 100644 index 000000000..864347e79 --- /dev/null +++ b/lib/Mount/GroupFolderEncryptionJail.php @@ -0,0 +1,44 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\GroupFolders\Mount; + +use OC\Files\Cache\Wrapper\CacheJail; +use OC\Files\Storage\Wrapper\Jail; + +/** + * Jail with overridden behaviors specific to group folders when encryption is + * enabled. + */ +class GroupFolderEncryptionJail extends Jail { + public function getCache($path = '', $storage = null) { + if (!$storage) { + $storage = $this->getWrapperStorage(); + } + // By default the Jail reuses the inner cache, but when encryption is + // enabled the storage needs to be passed to the cache so it takes into + // account the outer Encryption wrapper. + $sourceCache = $this->getWrapperStorage()->getCache($this->getUnjailedPath($path), $storage); + return new CacheJail($sourceCache, $this->rootPath); + } +} diff --git a/lib/Mount/MountProvider.php b/lib/Mount/MountProvider.php index 901592846..eb4dc6618 100644 --- a/lib/Mount/MountProvider.php +++ b/lib/Mount/MountProvider.php @@ -230,11 +230,11 @@ public function getMount( $cacheEntry['permissions'] &= $aclRootPermissions; } - $baseStorage = new Jail([ - 'storage' => $storage, - 'root' => $rootPath - ]); if ($this->enableEncryption) { + $baseStorage = new GroupFolderEncryptionJail([ + 'storage' => $storage, + 'root' => $rootPath + ]); $quotaStorage = new GroupFolderStorage([ 'storage' => $baseStorage, 'quota' => $quota, @@ -244,6 +244,10 @@ public function getMount( 'mountOwner' => $user, ]); } else { + $baseStorage = new Jail([ + 'storage' => $storage, + 'root' => $rootPath + ]); $quotaStorage = new GroupFolderNoEncryptionStorage([ 'storage' => $baseStorage, 'quota' => $quota,