Completed
Push — master ( 6ba4ca...cd1c45 )
by Blizzz
28:56
created
lib/private/Files/Config/UserMountCacheListener.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@
 block discarded – undo
29 29
  * Listen to hooks and update the mount cache as needed
30 30
  */
31 31
 class UserMountCacheListener {
32
-	/**
33
-	 * @var IUserMountCache
34
-	 */
35
-	private $userMountCache;
32
+    /**
33
+     * @var IUserMountCache
34
+     */
35
+    private $userMountCache;
36 36
 
37
-	/**
38
-	 * UserMountCacheListener constructor.
39
-	 *
40
-	 * @param IUserMountCache $userMountCache
41
-	 */
42
-	public function __construct(IUserMountCache $userMountCache) {
43
-		$this->userMountCache = $userMountCache;
44
-	}
37
+    /**
38
+     * UserMountCacheListener constructor.
39
+     *
40
+     * @param IUserMountCache $userMountCache
41
+     */
42
+    public function __construct(IUserMountCache $userMountCache) {
43
+        $this->userMountCache = $userMountCache;
44
+    }
45 45
 
46
-	public function listen(Manager $manager) {
47
-		$manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']);
48
-	}
46
+    public function listen(Manager $manager) {
47
+        $manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']);
48
+    }
49 49
 }
Please login to merge, or discard this patch.
lib/private/Files/Notify/RenameChange.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@
 block discarded – undo
26 26
 use OCP\Files\Notify\IRenameChange;
27 27
 
28 28
 class RenameChange extends Change implements IRenameChange {
29
-	/** @var string */
30
-	private $targetPath;
29
+    /** @var string */
30
+    private $targetPath;
31 31
 
32
-	/**
33
-	 * Change constructor.
34
-	 *
35
-	 * @param int $type
36
-	 * @param string $path
37
-	 * @param string $targetPath
38
-	 */
39
-	public function __construct($type, $path, $targetPath) {
40
-		parent::__construct($type, $path);
41
-		$this->targetPath = $targetPath;
42
-	}
32
+    /**
33
+     * Change constructor.
34
+     *
35
+     * @param int $type
36
+     * @param string $path
37
+     * @param string $targetPath
38
+     */
39
+    public function __construct($type, $path, $targetPath) {
40
+        parent::__construct($type, $path);
41
+        $this->targetPath = $targetPath;
42
+    }
43 43
 
44
-	/**
45
-	 * Get the new path of the renamed file relative to the storage root
46
-	 *
47
-	 * @return string
48
-	 */
49
-	public function getTargetPath() {
50
-		return $this->targetPath;
51
-	}
44
+    /**
45
+     * Get the new path of the renamed file relative to the storage root
46
+     *
47
+     * @return string
48
+     */
49
+    public function getTargetPath() {
50
+        return $this->targetPath;
51
+    }
52 52
 }
Please login to merge, or discard this patch.
lib/private/Files/Notify/Change.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -26,40 +26,40 @@
 block discarded – undo
26 26
 use OCP\Files\Notify\IChange;
27 27
 
28 28
 class Change implements IChange {
29
-	/** @var int */
30
-	private $type;
29
+    /** @var int */
30
+    private $type;
31 31
 
32
-	/** @var string */
33
-	private $path;
32
+    /** @var string */
33
+    private $path;
34 34
 
35
-	/**
36
-	 * Change constructor.
37
-	 *
38
-	 * @param int $type
39
-	 * @param string $path
40
-	 */
41
-	public function __construct($type, $path) {
42
-		$this->type = $type;
43
-		$this->path = $path;
44
-	}
35
+    /**
36
+     * Change constructor.
37
+     *
38
+     * @param int $type
39
+     * @param string $path
40
+     */
41
+    public function __construct($type, $path) {
42
+        $this->type = $type;
43
+        $this->path = $path;
44
+    }
45 45
 
46
-	/**
47
-	 * Get the type of the change
48
-	 *
49
-	 * @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED
50
-	 */
51
-	public function getType() {
52
-		return $this->type;
53
-	}
46
+    /**
47
+     * Get the type of the change
48
+     *
49
+     * @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED
50
+     */
51
+    public function getType() {
52
+        return $this->type;
53
+    }
54 54
 
55
-	/**
56
-	 * Get the path of the file that was changed relative to the root of the storage
57
-	 *
58
-	 * Note, for rename changes this path is the old path for the file
59
-	 *
60
-	 * @return mixed
61
-	 */
62
-	public function getPath() {
63
-		return $this->path;
64
-	}
55
+    /**
56
+     * Get the path of the file that was changed relative to the root of the storage
57
+     *
58
+     * Note, for rename changes this path is the old path for the file
59
+     *
60
+     * @return mixed
61
+     */
62
+    public function getPath() {
63
+        return $this->path;
64
+    }
65 65
 }
Please login to merge, or discard this patch.
Middleware/Security/Exceptions/CrossSiteRequestForgeryException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
  * @package OC\AppFramework\Middleware\Security\Exceptions
35 35
  */
36 36
 class CrossSiteRequestForgeryException extends SecurityException {
37
-	public function __construct() {
38
-		parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED);
39
-	}
37
+    public function __construct() {
38
+        parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED);
39
+    }
40 40
 }
Please login to merge, or discard this patch.
AppFramework/Middleware/Security/Exceptions/AppNotEnabledException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
  * @package OC\AppFramework\Middleware\Security\Exceptions
35 35
  */
36 36
 class AppNotEnabledException extends SecurityException {
37
-	public function __construct() {
38
-		parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED);
39
-	}
37
+    public function __construct() {
38
+        parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED);
39
+    }
40 40
 }
Please login to merge, or discard this patch.
AppFramework/Middleware/Security/Exceptions/NotLoggedInException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
  * @package OC\AppFramework\Middleware\Security\Exceptions
35 35
  */
36 36
 class NotLoggedInException extends SecurityException {
37
-	public function __construct() {
38
-		parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED);
39
-	}
37
+    public function __construct() {
38
+        parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED);
39
+    }
40 40
 }
Please login to merge, or discard this patch.
lib/private/DB/AdapterOCI8.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 		}
34 34
 		if ($table !== null) {
35 35
 			$suffix = '_SEQ';
36
-			$table = '"' . $table . $suffix . '"';
36
+			$table = '"'.$table.$suffix.'"';
37 37
 		}
38 38
 		return $this->conn->realLastInsertId($table);
39 39
 	}
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,24 +26,24 @@
 block discarded – undo
26 26
 namespace OC\DB;
27 27
 
28 28
 class AdapterOCI8 extends Adapter {
29
-	public function lastInsertId($table) {
30
-		if (is_null($table)) {
31
-			throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
32
-		}
33
-		if ($table !== null) {
34
-			$suffix = '_SEQ';
35
-			$table = '"' . $table . $suffix . '"';
36
-		}
37
-		return $this->conn->realLastInsertId($table);
38
-	}
29
+    public function lastInsertId($table) {
30
+        if (is_null($table)) {
31
+            throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
32
+        }
33
+        if ($table !== null) {
34
+            $suffix = '_SEQ';
35
+            $table = '"' . $table . $suffix . '"';
36
+        }
37
+        return $this->conn->realLastInsertId($table);
38
+    }
39 39
 
40
-	public const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
40
+    public const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400";
41 41
 
42
-	public function fixupStatement($statement) {
43
-		$statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement);
44
-		$statement = str_replace('`', '"', $statement);
45
-		$statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
46
-		$statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
47
-		return $statement;
48
-	}
42
+    public function fixupStatement($statement) {
43
+        $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement);
44
+        $statement = str_replace('`', '"', $statement);
45
+        $statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement);
46
+        $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement);
47
+        return $statement;
48
+    }
49 49
 }
Please login to merge, or discard this patch.
lib/private/Encryption/Exceptions/ModuleAlreadyExistsException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 * @param string $name
33 33
 	 */
34 34
 	public function __construct($id, $name) {
35
-		parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"');
35
+		parent::__construct('Id "'.$id.'" already used by encryption module "'.$name.'"');
36 36
 	}
37 37
 
38 38
 }
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
25 25
 use OCP\Encryption\Exceptions\GenericEncryptionException;
26 26
 
27 27
 class ModuleAlreadyExistsException extends GenericEncryptionException {
28
-	/**
29
-	 * @param string $id
30
-	 * @param string $name
31
-	 */
32
-	public function __construct($id, $name) {
33
-		parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"');
34
-	}
28
+    /**
29
+     * @param string $id
30
+     * @param string $name
31
+     */
32
+    public function __construct($id, $name) {
33
+        parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"');
34
+    }
35 35
 }
Please login to merge, or discard this patch.
lib/private/Encryption/Manager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@
 block discarded – undo
274 274
 		}
275 275
 
276 276
 		// check if key storage is mounted correctly
277
-		if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) {
277
+		if ($this->rootView->file_exists($rootDir.'/'.Storage::KEY_STORAGE_MARKER)) {
278 278
 			return true;
279 279
 		}
280 280
 
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -21,210 +21,210 @@
 block discarded – undo
21 21
 use Psr\Log\LoggerInterface;
22 22
 
23 23
 class Manager implements IManager {
24
-	protected array $encryptionModules;
25
-
26
-	public function __construct(
27
-		protected IConfig $config,
28
-		protected LoggerInterface $logger,
29
-		protected IL10N $l,
30
-		protected View $rootView,
31
-		protected Util $util,
32
-		protected ArrayCache $arrayCache,
33
-	) {
34
-		$this->encryptionModules = [];
35
-	}
36
-
37
-	/**
38
-	 * Check if encryption is enabled
39
-	 *
40
-	 * @return bool true if enabled, false if not
41
-	 */
42
-	public function isEnabled() {
43
-		$installed = $this->config->getSystemValueBool('installed', false);
44
-		if (!$installed) {
45
-			return false;
46
-		}
47
-
48
-		$enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no');
49
-		return $enabled === 'yes';
50
-	}
51
-
52
-	/**
53
-	 * check if new encryption is ready
54
-	 *
55
-	 * @return bool
56
-	 * @throws ServiceUnavailableException
57
-	 */
58
-	public function isReady() {
59
-		if ($this->isKeyStorageReady() === false) {
60
-			throw new ServiceUnavailableException('Key Storage is not ready');
61
-		}
62
-
63
-		return true;
64
-	}
65
-
66
-	/**
67
-	 * @param string $user
68
-	 */
69
-	public function isReadyForUser($user) {
70
-		if (!$this->isReady()) {
71
-			return false;
72
-		}
73
-
74
-		foreach ($this->getEncryptionModules() as $module) {
75
-			/** @var IEncryptionModule $m */
76
-			$m = call_user_func($module['callback']);
77
-			if (!$m->isReadyForUser($user)) {
78
-				return false;
79
-			}
80
-		}
81
-
82
-		return true;
83
-	}
84
-
85
-	/**
86
-	 * Registers an callback function which must return an encryption module instance
87
-	 *
88
-	 * @param string $id
89
-	 * @param string $displayName
90
-	 * @param callable $callback
91
-	 * @throws Exceptions\ModuleAlreadyExistsException
92
-	 */
93
-	public function registerEncryptionModule($id, $displayName, callable $callback) {
94
-		if (isset($this->encryptionModules[$id])) {
95
-			throw new Exceptions\ModuleAlreadyExistsException($id, $displayName);
96
-		}
97
-
98
-		$this->encryptionModules[$id] = [
99
-			'id' => $id,
100
-			'displayName' => $displayName,
101
-			'callback' => $callback,
102
-		];
103
-
104
-		$defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId();
105
-
106
-		if (empty($defaultEncryptionModuleId)) {
107
-			$this->setDefaultEncryptionModule($id);
108
-		}
109
-	}
110
-
111
-	/**
112
-	 * Unregisters an encryption module
113
-	 *
114
-	 * @param string $moduleId
115
-	 */
116
-	public function unregisterEncryptionModule($moduleId) {
117
-		unset($this->encryptionModules[$moduleId]);
118
-	}
119
-
120
-	/**
121
-	 * get a list of all encryption modules
122
-	 *
123
-	 * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
124
-	 */
125
-	public function getEncryptionModules() {
126
-		return $this->encryptionModules;
127
-	}
128
-
129
-	/**
130
-	 * get a specific encryption module
131
-	 *
132
-	 * @param string $moduleId
133
-	 * @return IEncryptionModule
134
-	 * @throws Exceptions\ModuleDoesNotExistsException
135
-	 */
136
-	public function getEncryptionModule($moduleId = '') {
137
-		if (empty($moduleId)) {
138
-			return $this->getDefaultEncryptionModule();
139
-		}
140
-		if (isset($this->encryptionModules[$moduleId])) {
141
-			return call_user_func($this->encryptionModules[$moduleId]['callback']);
142
-		}
143
-		$message = "Module with ID: $moduleId does not exist.";
144
-		$hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]);
145
-		throw new Exceptions\ModuleDoesNotExistsException($message, $hint);
146
-	}
147
-
148
-	/**
149
-	 * get default encryption module
150
-	 *
151
-	 * @return \OCP\Encryption\IEncryptionModule
152
-	 * @throws Exceptions\ModuleDoesNotExistsException
153
-	 */
154
-	protected function getDefaultEncryptionModule() {
155
-		$defaultModuleId = $this->getDefaultEncryptionModuleId();
156
-		if (empty($defaultModuleId)) {
157
-			$message = 'No default encryption module defined';
158
-			throw new Exceptions\ModuleDoesNotExistsException($message);
159
-		}
160
-		if (isset($this->encryptionModules[$defaultModuleId])) {
161
-			return call_user_func($this->encryptionModules[$defaultModuleId]['callback']);
162
-		}
163
-		$message = 'Default encryption module not loaded';
164
-		throw new Exceptions\ModuleDoesNotExistsException($message);
165
-	}
166
-
167
-	/**
168
-	 * set default encryption module Id
169
-	 *
170
-	 * @param string $moduleId
171
-	 * @return bool
172
-	 */
173
-	public function setDefaultEncryptionModule($moduleId) {
174
-		try {
175
-			$this->getEncryptionModule($moduleId);
176
-		} catch (\Exception $e) {
177
-			return false;
178
-		}
179
-
180
-		$this->config->setAppValue('core', 'default_encryption_module', $moduleId);
181
-		return true;
182
-	}
183
-
184
-	/**
185
-	 * get default encryption module Id
186
-	 *
187
-	 * @return string
188
-	 */
189
-	public function getDefaultEncryptionModuleId() {
190
-		return $this->config->getAppValue('core', 'default_encryption_module');
191
-	}
192
-
193
-	/**
194
-	 * Add storage wrapper
195
-	 */
196
-	public function setupStorage() {
197
-		// If encryption is disabled and there are no loaded modules it makes no sense to load the wrapper
198
-		if (!empty($this->encryptionModules) || $this->isEnabled()) {
199
-			$encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger);
200
-			Filesystem::addStorageWrapper('oc_encryption', [$encryptionWrapper, 'wrapStorage'], 2);
201
-		}
202
-	}
203
-
204
-	public function forceWrapStorage(IMountPoint $mountPoint, IStorage $storage) {
205
-		$encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger);
206
-		return $encryptionWrapper->wrapStorage($mountPoint->getMountPoint(), $storage, $mountPoint, true);
207
-	}
208
-
209
-
210
-	/**
211
-	 * check if key storage is ready
212
-	 *
213
-	 * @return bool
214
-	 */
215
-	protected function isKeyStorageReady() {
216
-		$rootDir = $this->util->getKeyStorageRoot();
217
-
218
-		// the default root is always valid
219
-		if ($rootDir === '') {
220
-			return true;
221
-		}
222
-
223
-		// check if key storage is mounted correctly
224
-		if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) {
225
-			return true;
226
-		}
227
-
228
-		return false;
229
-	}
24
+    protected array $encryptionModules;
25
+
26
+    public function __construct(
27
+        protected IConfig $config,
28
+        protected LoggerInterface $logger,
29
+        protected IL10N $l,
30
+        protected View $rootView,
31
+        protected Util $util,
32
+        protected ArrayCache $arrayCache,
33
+    ) {
34
+        $this->encryptionModules = [];
35
+    }
36
+
37
+    /**
38
+     * Check if encryption is enabled
39
+     *
40
+     * @return bool true if enabled, false if not
41
+     */
42
+    public function isEnabled() {
43
+        $installed = $this->config->getSystemValueBool('installed', false);
44
+        if (!$installed) {
45
+            return false;
46
+        }
47
+
48
+        $enabled = $this->config->getAppValue('core', 'encryption_enabled', 'no');
49
+        return $enabled === 'yes';
50
+    }
51
+
52
+    /**
53
+     * check if new encryption is ready
54
+     *
55
+     * @return bool
56
+     * @throws ServiceUnavailableException
57
+     */
58
+    public function isReady() {
59
+        if ($this->isKeyStorageReady() === false) {
60
+            throw new ServiceUnavailableException('Key Storage is not ready');
61
+        }
62
+
63
+        return true;
64
+    }
65
+
66
+    /**
67
+     * @param string $user
68
+     */
69
+    public function isReadyForUser($user) {
70
+        if (!$this->isReady()) {
71
+            return false;
72
+        }
73
+
74
+        foreach ($this->getEncryptionModules() as $module) {
75
+            /** @var IEncryptionModule $m */
76
+            $m = call_user_func($module['callback']);
77
+            if (!$m->isReadyForUser($user)) {
78
+                return false;
79
+            }
80
+        }
81
+
82
+        return true;
83
+    }
84
+
85
+    /**
86
+     * Registers an callback function which must return an encryption module instance
87
+     *
88
+     * @param string $id
89
+     * @param string $displayName
90
+     * @param callable $callback
91
+     * @throws Exceptions\ModuleAlreadyExistsException
92
+     */
93
+    public function registerEncryptionModule($id, $displayName, callable $callback) {
94
+        if (isset($this->encryptionModules[$id])) {
95
+            throw new Exceptions\ModuleAlreadyExistsException($id, $displayName);
96
+        }
97
+
98
+        $this->encryptionModules[$id] = [
99
+            'id' => $id,
100
+            'displayName' => $displayName,
101
+            'callback' => $callback,
102
+        ];
103
+
104
+        $defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId();
105
+
106
+        if (empty($defaultEncryptionModuleId)) {
107
+            $this->setDefaultEncryptionModule($id);
108
+        }
109
+    }
110
+
111
+    /**
112
+     * Unregisters an encryption module
113
+     *
114
+     * @param string $moduleId
115
+     */
116
+    public function unregisterEncryptionModule($moduleId) {
117
+        unset($this->encryptionModules[$moduleId]);
118
+    }
119
+
120
+    /**
121
+     * get a list of all encryption modules
122
+     *
123
+     * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
124
+     */
125
+    public function getEncryptionModules() {
126
+        return $this->encryptionModules;
127
+    }
128
+
129
+    /**
130
+     * get a specific encryption module
131
+     *
132
+     * @param string $moduleId
133
+     * @return IEncryptionModule
134
+     * @throws Exceptions\ModuleDoesNotExistsException
135
+     */
136
+    public function getEncryptionModule($moduleId = '') {
137
+        if (empty($moduleId)) {
138
+            return $this->getDefaultEncryptionModule();
139
+        }
140
+        if (isset($this->encryptionModules[$moduleId])) {
141
+            return call_user_func($this->encryptionModules[$moduleId]['callback']);
142
+        }
143
+        $message = "Module with ID: $moduleId does not exist.";
144
+        $hint = $this->l->t('Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator.', [$moduleId]);
145
+        throw new Exceptions\ModuleDoesNotExistsException($message, $hint);
146
+    }
147
+
148
+    /**
149
+     * get default encryption module
150
+     *
151
+     * @return \OCP\Encryption\IEncryptionModule
152
+     * @throws Exceptions\ModuleDoesNotExistsException
153
+     */
154
+    protected function getDefaultEncryptionModule() {
155
+        $defaultModuleId = $this->getDefaultEncryptionModuleId();
156
+        if (empty($defaultModuleId)) {
157
+            $message = 'No default encryption module defined';
158
+            throw new Exceptions\ModuleDoesNotExistsException($message);
159
+        }
160
+        if (isset($this->encryptionModules[$defaultModuleId])) {
161
+            return call_user_func($this->encryptionModules[$defaultModuleId]['callback']);
162
+        }
163
+        $message = 'Default encryption module not loaded';
164
+        throw new Exceptions\ModuleDoesNotExistsException($message);
165
+    }
166
+
167
+    /**
168
+     * set default encryption module Id
169
+     *
170
+     * @param string $moduleId
171
+     * @return bool
172
+     */
173
+    public function setDefaultEncryptionModule($moduleId) {
174
+        try {
175
+            $this->getEncryptionModule($moduleId);
176
+        } catch (\Exception $e) {
177
+            return false;
178
+        }
179
+
180
+        $this->config->setAppValue('core', 'default_encryption_module', $moduleId);
181
+        return true;
182
+    }
183
+
184
+    /**
185
+     * get default encryption module Id
186
+     *
187
+     * @return string
188
+     */
189
+    public function getDefaultEncryptionModuleId() {
190
+        return $this->config->getAppValue('core', 'default_encryption_module');
191
+    }
192
+
193
+    /**
194
+     * Add storage wrapper
195
+     */
196
+    public function setupStorage() {
197
+        // If encryption is disabled and there are no loaded modules it makes no sense to load the wrapper
198
+        if (!empty($this->encryptionModules) || $this->isEnabled()) {
199
+            $encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger);
200
+            Filesystem::addStorageWrapper('oc_encryption', [$encryptionWrapper, 'wrapStorage'], 2);
201
+        }
202
+    }
203
+
204
+    public function forceWrapStorage(IMountPoint $mountPoint, IStorage $storage) {
205
+        $encryptionWrapper = new EncryptionWrapper($this->arrayCache, $this, $this->logger);
206
+        return $encryptionWrapper->wrapStorage($mountPoint->getMountPoint(), $storage, $mountPoint, true);
207
+    }
208
+
209
+
210
+    /**
211
+     * check if key storage is ready
212
+     *
213
+     * @return bool
214
+     */
215
+    protected function isKeyStorageReady() {
216
+        $rootDir = $this->util->getKeyStorageRoot();
217
+
218
+        // the default root is always valid
219
+        if ($rootDir === '') {
220
+            return true;
221
+        }
222
+
223
+        // check if key storage is mounted correctly
224
+        if ($this->rootView->file_exists($rootDir . '/' . Storage::KEY_STORAGE_MARKER)) {
225
+            return true;
226
+        }
227
+
228
+        return false;
229
+    }
230 230
 }
Please login to merge, or discard this patch.