Skip to content

Commit 13b6f92

Browse files
authored
Revert "fix(encryption): Refactor EncryptionWrapper with HomeMountPoint support"
1 parent 4eb8bc8 commit 13b6f92

1 file changed

Lines changed: 25 additions & 43 deletions

File tree

lib/private/Encryption/EncryptionWrapper.php

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace OC\Encryption;
99

1010
use OC\Files\Filesystem;
11-
use OC\Files\Mount\HomeMountPoint;
1211
use OC\Files\Storage\Wrapper\Encryption;
1312
use OC\Files\View;
1413
use OC\Memcache\ArrayCache;
@@ -17,7 +16,6 @@
1716
use OCP\Files\Mount\IMountPoint;
1817
use OCP\Files\Storage\IDisableEncryptionStorage;
1918
use OCP\Files\Storage\IStorage;
20-
use OCP\IAppConfig;
2119
use OCP\IConfig;
2220
use OCP\IGroupManager;
2321
use OCP\IUserManager;
@@ -59,48 +57,32 @@ public function wrapStorage(string $mountPoint, IStorage $storage, IMountPoint $
5957
'mount' => $mount
6058
];
6159

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);
6866

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;
7986
}
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-
);
10587
}
10688
}

0 commit comments

Comments
 (0)