1414use OC \Memcache \ArrayCache ;
1515use OCP \Encryption \IFile ;
1616use OCP \Encryption \Keys \IStorage as EncryptionKeysStorage ;
17- use OCP \Exceptions \AppConfigTypeConflictException ;
1817use OCP \Files \Mount \IMountPoint ;
1918use OCP \Files \Storage \IDisableEncryptionStorage ;
2019use OCP \Files \Storage \IStorage ;
@@ -40,6 +39,7 @@ class EncryptionWrapper {
4039 public function __construct (
4140 private ArrayCache $ arrayCache ,
4241 private Manager $ manager ,
42+ private IAppConfig $ appConfig ,
4343 private LoggerInterface $ logger ,
4444 ) {
4545 }
@@ -73,7 +73,8 @@ public function wrapStorage(string $mountPoint, IStorage $storage, IMountPoint $
7373 }
7474
7575 // Skip encryption for home mounts if encryptHomeStorage is disabled
76- if ($ mount instanceof HomeMountPoint && !$ this ->shouldEncryptHomeStorage ()) {
76+ if ($ mount instanceof HomeMountPoint &&
77+ !$ this ->appConfig ->getValueBool ('encryption ' , 'encryptHomeStorage ' , true )) {
7778 return $ storage ;
7879 }
7980 }
@@ -103,24 +104,4 @@ public function wrapStorage(string $mountPoint, IStorage $storage, IMountPoint $
103104 $ this ->arrayCache
104105 );
105106 }
106-
107- private function shouldEncryptHomeStorage (): bool {
108- $ appConfig = Server::get (IAppConfig::class);
109- try {
110- return $ appConfig ->getValueBool ('encryption ' , 'encryptHomeStorage ' , true );
111- } catch (AppConfigTypeConflictException ) {
112- // Stored as VALUE_STRING from a pre-upgrade installation.
113- // RetypeEncryptionConfigKeys repair step will fix the type on occ upgrade.
114- return $ this ->parseLegacyBoolString (
115- $ appConfig ->getValueString ('encryption ' , 'encryptHomeStorage ' , '1 ' )
116- );
117- } catch (\Throwable ) {
118- // DB not ready (e.g. oc_appconfig does not yet exist during install).
119- return true ;
120- }
121- }
122-
123- private function parseLegacyBoolString (string $ value ): bool {
124- return in_array (strtolower (trim ($ value )), ['1 ' , 'true ' , 'yes ' , 'on ' ], true );
125- }
126107}
0 commit comments