|
8 | 8 | namespace OC\Encryption; |
9 | 9 |
|
10 | 10 | use OC\Files\Filesystem; |
11 | | -use OC\Files\Mount\HomeMountPoint; |
12 | 11 | use OC\Files\Storage\Wrapper\Encryption; |
13 | 12 | use OC\Files\View; |
14 | 13 | use OC\Memcache\ArrayCache; |
|
17 | 16 | use OCP\Files\Mount\IMountPoint; |
18 | 17 | use OCP\Files\Storage\IDisableEncryptionStorage; |
19 | 18 | use OCP\Files\Storage\IStorage; |
20 | | -use OCP\IAppConfig; |
21 | 19 | use OCP\IConfig; |
22 | 20 | use OCP\IGroupManager; |
23 | 21 | use OCP\IUserManager; |
@@ -59,48 +57,32 @@ public function wrapStorage(string $mountPoint, IStorage $storage, IMountPoint $ |
59 | 57 | 'mount' => $mount |
60 | 58 | ]; |
61 | 59 |
|
62 | | - // Only evaluate other conditions if not forced |
63 | | - if (!$force) { |
64 | | - // If a disabled storage medium, return basic storage |
65 | | - if ($storage->instanceOfStorage(IDisableEncryptionStorage::class)) { |
66 | | - return $storage; |
67 | | - } |
| 60 | + if ($force || (!$storage->instanceOfStorage(IDisableEncryptionStorage::class) && $mountPoint !== '/')) { |
| 61 | + $user = Server::get(IUserSession::class)->getUser(); |
| 62 | + $mountManager = Filesystem::getMountManager(); |
| 63 | + $uid = $user ? $user->getUID() : null; |
| 64 | + $fileHelper = Server::get(IFile::class); |
| 65 | + $keyStorage = Server::get(EncryptionKeysStorage::class); |
68 | 66 |
|
69 | | - // Root mount point handling: skip encryption wrapper |
70 | | - if ($mountPoint === '/') { |
71 | | - return $storage; |
72 | | - } |
73 | | - |
74 | | - // Skip encryption for home mounts if encryptHomeStorage is disabled |
75 | | - if ($mount instanceof HomeMountPoint |
76 | | - && !Server::get(IAppConfig::class)->getValueBool('encryption', 'encryptHomeStorage', true)) { |
77 | | - return $storage; |
78 | | - } |
| 67 | + $util = new Util( |
| 68 | + new View(), |
| 69 | + Server::get(IUserManager::class), |
| 70 | + Server::get(IGroupManager::class), |
| 71 | + Server::get(IConfig::class) |
| 72 | + ); |
| 73 | + return new Encryption( |
| 74 | + $parameters, |
| 75 | + $this->manager, |
| 76 | + $util, |
| 77 | + $this->logger, |
| 78 | + $fileHelper, |
| 79 | + $uid, |
| 80 | + $keyStorage, |
| 81 | + $mountManager, |
| 82 | + $this->arrayCache |
| 83 | + ); |
| 84 | + } else { |
| 85 | + return $storage; |
79 | 86 | } |
80 | | - |
81 | | - // Apply encryption wrapper |
82 | | - $user = Server::get(IUserSession::class)->getUser(); |
83 | | - $mountManager = Filesystem::getMountManager(); |
84 | | - $uid = $user ? $user->getUID() : null; |
85 | | - $fileHelper = Server::get(IFile::class); |
86 | | - $keyStorage = Server::get(EncryptionKeysStorage::class); |
87 | | - |
88 | | - $util = new Util( |
89 | | - new View(), |
90 | | - Server::get(IUserManager::class), |
91 | | - Server::get(IGroupManager::class), |
92 | | - Server::get(IConfig::class) |
93 | | - ); |
94 | | - return new Encryption( |
95 | | - $parameters, |
96 | | - $this->manager, |
97 | | - $util, |
98 | | - $this->logger, |
99 | | - $fileHelper, |
100 | | - $uid, |
101 | | - $keyStorage, |
102 | | - $mountManager, |
103 | | - $this->arrayCache |
104 | | - ); |
105 | 87 | } |
106 | 88 | } |
0 commit comments