Completed
Push — master ( 08b58a...0efd05 )
by Daniel
30:08 queued 21s
created
apps/user_ldap/lib/ILDAPGroupPlugin.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -26,61 +26,61 @@
 block discarded – undo
26 26
 
27 27
 interface ILDAPGroupPlugin {
28 28
 
29
-	/**
30
-	 * Check if plugin implements actions
31
-	 * @return int
32
-	 *
33
-	 * Returns the supported actions as int to be
34
-	 * compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
35
-	 */
36
-	public function respondToActions();
29
+    /**
30
+     * Check if plugin implements actions
31
+     * @return int
32
+     *
33
+     * Returns the supported actions as int to be
34
+     * compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
35
+     */
36
+    public function respondToActions();
37 37
 
38
-	/**
39
-	 * @param string $gid
40
-	 * @return string|null The group DN if group creation was successful.
41
-	 */
42
-	public function createGroup($gid);
38
+    /**
39
+     * @param string $gid
40
+     * @return string|null The group DN if group creation was successful.
41
+     */
42
+    public function createGroup($gid);
43 43
 
44
-	/**
45
-	 * delete a group
46
-	 * @param string $gid gid of the group to delete
47
-	 * @return bool
48
-	 */
49
-	public function deleteGroup($gid);
44
+    /**
45
+     * delete a group
46
+     * @param string $gid gid of the group to delete
47
+     * @return bool
48
+     */
49
+    public function deleteGroup($gid);
50 50
 
51
-	/**
52
-	 * Add a user to a group
53
-	 * @param string $uid Name of the user to add to group
54
-	 * @param string $gid Name of the group in which add the user
55
-	 * @return bool
56
-	 *
57
-	 * Adds a user to a group.
58
-	 */
59
-	public function addToGroup($uid, $gid);
51
+    /**
52
+     * Add a user to a group
53
+     * @param string $uid Name of the user to add to group
54
+     * @param string $gid Name of the group in which add the user
55
+     * @return bool
56
+     *
57
+     * Adds a user to a group.
58
+     */
59
+    public function addToGroup($uid, $gid);
60 60
 
61
-	/**
62
-	 * Removes a user from a group
63
-	 * @param string $uid Name of the user to remove from group
64
-	 * @param string $gid Name of the group from which remove the user
65
-	 * @return bool
66
-	 *
67
-	 * removes the user from a group.
68
-	 */
69
-	public function removeFromGroup($uid, $gid);
61
+    /**
62
+     * Removes a user from a group
63
+     * @param string $uid Name of the user to remove from group
64
+     * @param string $gid Name of the group from which remove the user
65
+     * @return bool
66
+     *
67
+     * removes the user from a group.
68
+     */
69
+    public function removeFromGroup($uid, $gid);
70 70
 
71
-	/**
72
-	 * get the number of all users matching the search string in a group
73
-	 * @param string $gid
74
-	 * @param string $search
75
-	 * @return int|false
76
-	 */
77
-	public function countUsersInGroup($gid, $search = '');
71
+    /**
72
+     * get the number of all users matching the search string in a group
73
+     * @param string $gid
74
+     * @param string $search
75
+     * @return int|false
76
+     */
77
+    public function countUsersInGroup($gid, $search = '');
78 78
 
79
-	/**
80
-	 * get an array with group details
81
-	 * @param string $gid
82
-	 * @return array|false
83
-	 */
84
-	public function getGroupDetails($gid);
79
+    /**
80
+     * get an array with group details
81
+     * @param string $gid
82
+     * @return array|false
83
+     */
84
+    public function getGroupDetails($gid);
85 85
 
86 86
 }
Please login to merge, or discard this patch.
lib/public/Federation/ICloudId.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,35 +30,35 @@
 block discarded – undo
30 30
  * @since 12.0.0
31 31
  */
32 32
 interface ICloudId {
33
-	/**
34
-	 * The remote cloud id
35
-	 *
36
-	 * @return string
37
-	 * @since 12.0.0
38
-	 */
39
-	public function getId(): string;
33
+    /**
34
+     * The remote cloud id
35
+     *
36
+     * @return string
37
+     * @since 12.0.0
38
+     */
39
+    public function getId(): string;
40 40
 
41
-	/**
42
-	 * Get a clean representation of the cloud id for display
43
-	 *
44
-	 * @return string
45
-	 * @since 12.0.0
46
-	 */
47
-	public function getDisplayId(): string;
41
+    /**
42
+     * Get a clean representation of the cloud id for display
43
+     *
44
+     * @return string
45
+     * @since 12.0.0
46
+     */
47
+    public function getDisplayId(): string;
48 48
 
49
-	/**
50
-	 * The username on the remote server
51
-	 *
52
-	 * @return string
53
-	 * @since 12.0.0
54
-	 */
55
-	public function getUser(): string;
49
+    /**
50
+     * The username on the remote server
51
+     *
52
+     * @return string
53
+     * @since 12.0.0
54
+     */
55
+    public function getUser(): string;
56 56
 
57
-	/**
58
-	 * The base address of the remote server
59
-	 *
60
-	 * @return string
61
-	 * @since 12.0.0
62
-	 */
63
-	public function getRemote(): string;
57
+    /**
58
+     * The base address of the remote server
59
+     *
60
+     * @return string
61
+     * @since 12.0.0
62
+     */
63
+    public function getRemote(): string;
64 64
 }
Please login to merge, or discard this patch.
lib/public/Http/Client/IClientService.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
  * @since 8.1.0
32 32
  */
33 33
 interface IClientService {
34
-	/**
35
-	 * @return IClient
36
-	 * @since 8.1.0
37
-	 */
38
-	public function newClient(): IClient;
34
+    /**
35
+     * @return IClient
36
+     * @since 8.1.0
37
+     */
38
+    public function newClient(): IClient;
39 39
 }
Please login to merge, or discard this patch.
lib/public/Http/Client/IResponse.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,28 +32,28 @@
 block discarded – undo
32 32
  * @since 8.1.0
33 33
  */
34 34
 interface IResponse {
35
-	/**
36
-	 * @return string|resource
37
-	 * @since 8.1.0
38
-	 */
39
-	public function getBody();
35
+    /**
36
+     * @return string|resource
37
+     * @since 8.1.0
38
+     */
39
+    public function getBody();
40 40
 
41
-	/**
42
-	 * @return int
43
-	 * @since 8.1.0
44
-	 */
45
-	public function getStatusCode(): int;
41
+    /**
42
+     * @return int
43
+     * @since 8.1.0
44
+     */
45
+    public function getStatusCode(): int;
46 46
 
47
-	/**
48
-	 * @param string $key
49
-	 * @return string
50
-	 * @since 8.1.0
51
-	 */
52
-	public function getHeader(string $key): string;
47
+    /**
48
+     * @param string $key
49
+     * @return string
50
+     * @since 8.1.0
51
+     */
52
+    public function getHeader(string $key): string;
53 53
 
54
-	/**
55
-	 * @return array
56
-	 * @since 8.1.0
57
-	 */
58
-	public function getHeaders(): array;
54
+    /**
55
+     * @return array
56
+     * @since 8.1.0
57
+     */
58
+    public function getHeaders(): array;
59 59
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Service/StoragesService.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	protected function getStorageConfigFromDBMount(array $mount) {
75
-		$applicableUsers = array_filter($mount['applicable'], function ($applicable) {
75
+		$applicableUsers = array_filter($mount['applicable'], function($applicable) {
76 76
 			return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_USER;
77 77
 		});
78
-		$applicableUsers = array_map(function ($applicable) {
78
+		$applicableUsers = array_map(function($applicable) {
79 79
 			return $applicable['value'];
80 80
 		}, $applicableUsers);
81 81
 
82
-		$applicableGroups = array_filter($mount['applicable'], function ($applicable) {
82
+		$applicableGroups = array_filter($mount['applicable'], function($applicable) {
83 83
 			return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_GROUP;
84 84
 		});
85
-		$applicableGroups = array_map(function ($applicable) {
85
+		$applicableGroups = array_map(function($applicable) {
86 86
 			return $applicable['value'];
87 87
 		}, $applicableGroups);
88 88
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 				$mount['priority']
99 99
 			);
100 100
 			$config->setType($mount['type']);
101
-			$config->setId((int)$mount['mount_id']);
101
+			$config->setId((int) $mount['mount_id']);
102 102
 			return $config;
103 103
 		} catch (\UnexpectedValueException $e) {
104 104
 			// don't die if a storage backend doesn't exist
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	protected function readConfig() {
127 127
 		$mounts = $this->readDBConfig();
128 128
 		$configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
129
-		$configs = array_filter($configs, function ($config) {
129
+		$configs = array_filter($configs, function($config) {
130 130
 			return $config instanceof StorageConfig;
131 131
 		});
132 132
 
133
-		$keys = array_map(function (StorageConfig $config) {
133
+		$keys = array_map(function(StorageConfig $config) {
134 134
 			return $config->getId();
135 135
 		}, $configs);
136 136
 
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 		$mount = $this->dbConfig->getMountById($id);
150 150
 
151 151
 		if (!is_array($mount)) {
152
-			throw new NotFoundException('Storage with ID "' . $id . '" not found');
152
+			throw new NotFoundException('Storage with ID "'.$id.'" not found');
153 153
 		}
154 154
 
155 155
 		$config = $this->getStorageConfigFromDBMount($mount);
156 156
 		if ($this->isApplicable($config)) {
157 157
 			return $config;
158 158
 		} else {
159
-			throw new NotFoundException('Storage with ID "' . $id . '" not found');
159
+			throw new NotFoundException('Storage with ID "'.$id.'" not found');
160 160
 		}
161 161
 	}
162 162
 
@@ -379,13 +379,13 @@  discard block
 block discarded – undo
379 379
 		$existingMount = $this->dbConfig->getMountById($id);
380 380
 
381 381
 		if (!is_array($existingMount)) {
382
-			throw new NotFoundException('Storage with ID "' . $id . '" not found while updating storage');
382
+			throw new NotFoundException('Storage with ID "'.$id.'" not found while updating storage');
383 383
 		}
384 384
 
385 385
 		$oldStorage = $this->getStorageConfigFromDBMount($existingMount);
386 386
 
387 387
 		if ($oldStorage->getBackend() instanceof InvalidBackend) {
388
-			throw new NotFoundException('Storage with id "' . $id . '" cannot be edited due to missing backend');
388
+			throw new NotFoundException('Storage with id "'.$id.'" cannot be edited due to missing backend');
389 389
 		}
390 390
 
391 391
 		$removedUsers = array_diff($oldStorage->getApplicableUsers(), $updatedStorage->getApplicableUsers());
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		$existingMount = $this->dbConfig->getMountById($id);
463 463
 
464 464
 		if (!is_array($existingMount)) {
465
-			throw new NotFoundException('Storage with ID "' . $id . '" not found');
465
+			throw new NotFoundException('Storage with ID "'.$id.'" not found');
466 466
 		}
467 467
 
468 468
 		$this->dbConfig->removeMount($id);
Please login to merge, or discard this patch.
Indentation   +444 added lines, -444 removed lines patch added patch discarded remove patch
@@ -28,448 +28,448 @@
 block discarded – undo
28 28
  */
29 29
 abstract class StoragesService {
30 30
 
31
-	/**
32
-	 * @param BackendService $backendService
33
-	 * @param DBConfigService $dbConfig
34
-	 * @param IUserMountCache $userMountCache
35
-	 * @param IEventDispatcher $eventDispatcher
36
-	 */
37
-	public function __construct(
38
-		protected BackendService $backendService,
39
-		protected DBConfigService $dbConfig,
40
-		protected IUserMountCache $userMountCache,
41
-		protected IEventDispatcher $eventDispatcher,
42
-	) {
43
-	}
44
-
45
-	protected function readDBConfig() {
46
-		return $this->dbConfig->getAdminMounts();
47
-	}
48
-
49
-	protected function getStorageConfigFromDBMount(array $mount) {
50
-		$applicableUsers = array_filter($mount['applicable'], function ($applicable) {
51
-			return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_USER;
52
-		});
53
-		$applicableUsers = array_map(function ($applicable) {
54
-			return $applicable['value'];
55
-		}, $applicableUsers);
56
-
57
-		$applicableGroups = array_filter($mount['applicable'], function ($applicable) {
58
-			return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_GROUP;
59
-		});
60
-		$applicableGroups = array_map(function ($applicable) {
61
-			return $applicable['value'];
62
-		}, $applicableGroups);
63
-
64
-		try {
65
-			$config = $this->createStorage(
66
-				$mount['mount_point'],
67
-				$mount['storage_backend'],
68
-				$mount['auth_backend'],
69
-				$mount['config'],
70
-				$mount['options'],
71
-				array_values($applicableUsers),
72
-				array_values($applicableGroups),
73
-				$mount['priority']
74
-			);
75
-			$config->setType($mount['type']);
76
-			$config->setId((int)$mount['mount_id']);
77
-			return $config;
78
-		} catch (\UnexpectedValueException $e) {
79
-			// don't die if a storage backend doesn't exist
80
-			Server::get(LoggerInterface::class)->error('Could not load storage.', [
81
-				'app' => 'files_external',
82
-				'exception' => $e,
83
-			]);
84
-			return null;
85
-		} catch (\InvalidArgumentException $e) {
86
-			Server::get(LoggerInterface::class)->error('Could not load storage.', [
87
-				'app' => 'files_external',
88
-				'exception' => $e,
89
-			]);
90
-			return null;
91
-		}
92
-	}
93
-
94
-	/**
95
-	 * Read the external storage config
96
-	 *
97
-	 * @return array map of storage id to storage config
98
-	 */
99
-	protected function readConfig() {
100
-		$mounts = $this->readDBConfig();
101
-		$configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
102
-		$configs = array_filter($configs, function ($config) {
103
-			return $config instanceof StorageConfig;
104
-		});
105
-
106
-		$keys = array_map(function (StorageConfig $config) {
107
-			return $config->getId();
108
-		}, $configs);
109
-
110
-		return array_combine($keys, $configs);
111
-	}
112
-
113
-	/**
114
-	 * Get a storage with status
115
-	 *
116
-	 * @param int $id storage id
117
-	 *
118
-	 * @return StorageConfig
119
-	 * @throws NotFoundException if the storage with the given id was not found
120
-	 */
121
-	public function getStorage(int $id) {
122
-		$mount = $this->dbConfig->getMountById($id);
123
-
124
-		if (!is_array($mount)) {
125
-			throw new NotFoundException('Storage with ID "' . $id . '" not found');
126
-		}
127
-
128
-		$config = $this->getStorageConfigFromDBMount($mount);
129
-		if ($this->isApplicable($config)) {
130
-			return $config;
131
-		} else {
132
-			throw new NotFoundException('Storage with ID "' . $id . '" not found');
133
-		}
134
-	}
135
-
136
-	/**
137
-	 * Check whether this storage service should provide access to a storage
138
-	 *
139
-	 * @param StorageConfig $config
140
-	 * @return bool
141
-	 */
142
-	abstract protected function isApplicable(StorageConfig $config);
143
-
144
-	/**
145
-	 * Gets all storages, valid or not
146
-	 *
147
-	 * @return StorageConfig[] array of storage configs
148
-	 */
149
-	public function getAllStorages() {
150
-		return $this->readConfig();
151
-	}
152
-
153
-	/**
154
-	 * Gets all valid storages
155
-	 *
156
-	 * @return StorageConfig[]
157
-	 */
158
-	public function getStorages() {
159
-		return array_filter($this->getAllStorages(), [$this, 'validateStorage']);
160
-	}
161
-
162
-	/**
163
-	 * Validate storage
164
-	 * FIXME: De-duplicate with StoragesController::validate()
165
-	 *
166
-	 * @param StorageConfig $storage
167
-	 * @return bool
168
-	 */
169
-	protected function validateStorage(StorageConfig $storage) {
170
-		/** @var Backend */
171
-		$backend = $storage->getBackend();
172
-		/** @var AuthMechanism */
173
-		$authMechanism = $storage->getAuthMechanism();
174
-
175
-		if (!$backend->isVisibleFor($this->getVisibilityType())) {
176
-			// not permitted to use backend
177
-			return false;
178
-		}
179
-		if (!$authMechanism->isVisibleFor($this->getVisibilityType())) {
180
-			// not permitted to use auth mechanism
181
-			return false;
182
-		}
183
-
184
-		return true;
185
-	}
186
-
187
-	/**
188
-	 * Get the visibility type for this controller, used in validation
189
-	 *
190
-	 * @return int BackendService::VISIBILITY_* constants
191
-	 */
192
-	abstract public function getVisibilityType();
193
-
194
-	/**
195
-	 * @return integer
196
-	 */
197
-	protected function getType() {
198
-		return DBConfigService::MOUNT_TYPE_ADMIN;
199
-	}
200
-
201
-	/**
202
-	 * Add new storage to the configuration
203
-	 *
204
-	 * @param StorageConfig $newStorage storage attributes
205
-	 *
206
-	 * @return StorageConfig storage config, with added id
207
-	 */
208
-	public function addStorage(StorageConfig $newStorage) {
209
-		$allStorages = $this->readConfig();
210
-
211
-		$configId = $this->dbConfig->addMount(
212
-			$newStorage->getMountPoint(),
213
-			$newStorage->getBackend()->getIdentifier(),
214
-			$newStorage->getAuthMechanism()->getIdentifier(),
215
-			$newStorage->getPriority(),
216
-			$this->getType()
217
-		);
218
-
219
-		$newStorage->setId($configId);
220
-
221
-		foreach ($newStorage->getApplicableUsers() as $user) {
222
-			$this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_USER, $user);
223
-		}
224
-		foreach ($newStorage->getApplicableGroups() as $group) {
225
-			$this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
226
-		}
227
-		foreach ($newStorage->getBackendOptions() as $key => $value) {
228
-			$this->dbConfig->setConfig($configId, $key, $value);
229
-		}
230
-		foreach ($newStorage->getMountOptions() as $key => $value) {
231
-			$this->dbConfig->setOption($configId, $key, $value);
232
-		}
233
-
234
-		if (count($newStorage->getApplicableUsers()) === 0 && count($newStorage->getApplicableGroups()) === 0) {
235
-			$this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
236
-		}
237
-
238
-		// add new storage
239
-		$allStorages[$configId] = $newStorage;
240
-
241
-		$this->triggerHooks($newStorage, Filesystem::signal_create_mount);
242
-
243
-		$newStorage->setStatus(StorageNotAvailableException::STATUS_SUCCESS);
244
-		return $newStorage;
245
-	}
246
-
247
-	/**
248
-	 * Create a storage from its parameters
249
-	 *
250
-	 * @param string $mountPoint storage mount point
251
-	 * @param string $backendIdentifier backend identifier
252
-	 * @param string $authMechanismIdentifier authentication mechanism identifier
253
-	 * @param array $backendOptions backend-specific options
254
-	 * @param array|null $mountOptions mount-specific options
255
-	 * @param array|null $applicableUsers users for which to mount the storage
256
-	 * @param array|null $applicableGroups groups for which to mount the storage
257
-	 * @param int|null $priority priority
258
-	 *
259
-	 * @return StorageConfig
260
-	 */
261
-	public function createStorage(
262
-		$mountPoint,
263
-		$backendIdentifier,
264
-		$authMechanismIdentifier,
265
-		$backendOptions,
266
-		$mountOptions = null,
267
-		$applicableUsers = null,
268
-		$applicableGroups = null,
269
-		$priority = null,
270
-	) {
271
-		$backend = $this->backendService->getBackend($backendIdentifier);
272
-		if (!$backend) {
273
-			$backend = new InvalidBackend($backendIdentifier);
274
-		}
275
-		$authMechanism = $this->backendService->getAuthMechanism($authMechanismIdentifier);
276
-		if (!$authMechanism) {
277
-			$authMechanism = new InvalidAuth($authMechanismIdentifier);
278
-		}
279
-		$newStorage = new StorageConfig();
280
-		$newStorage->setMountPoint($mountPoint);
281
-		$newStorage->setBackend($backend);
282
-		$newStorage->setAuthMechanism($authMechanism);
283
-		$newStorage->setBackendOptions($backendOptions);
284
-		if (isset($mountOptions)) {
285
-			$newStorage->setMountOptions($mountOptions);
286
-		}
287
-		if (isset($applicableUsers)) {
288
-			$newStorage->setApplicableUsers($applicableUsers);
289
-		}
290
-		if (isset($applicableGroups)) {
291
-			$newStorage->setApplicableGroups($applicableGroups);
292
-		}
293
-		if (isset($priority)) {
294
-			$newStorage->setPriority($priority);
295
-		}
296
-
297
-		return $newStorage;
298
-	}
299
-
300
-	/**
301
-	 * Triggers the given hook signal for all the applicables given
302
-	 *
303
-	 * @param string $signal signal
304
-	 * @param string $mountPoint hook mount point param
305
-	 * @param string $mountType hook mount type param
306
-	 * @param array $applicableArray array of applicable users/groups for which to trigger the hook
307
-	 */
308
-	protected function triggerApplicableHooks($signal, $mountPoint, $mountType, $applicableArray): void {
309
-		$this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent(null));
310
-		foreach ($applicableArray as $applicable) {
311
-			Util::emitHook(
312
-				Filesystem::CLASSNAME,
313
-				$signal,
314
-				[
315
-					Filesystem::signal_param_path => $mountPoint,
316
-					Filesystem::signal_param_mount_type => $mountType,
317
-					Filesystem::signal_param_users => $applicable,
318
-				]
319
-			);
320
-		}
321
-	}
322
-
323
-	/**
324
-	 * Triggers $signal for all applicable users of the given
325
-	 * storage
326
-	 *
327
-	 * @param StorageConfig $storage storage data
328
-	 * @param string $signal signal to trigger
329
-	 */
330
-	abstract protected function triggerHooks(StorageConfig $storage, $signal);
331
-
332
-	/**
333
-	 * Triggers signal_create_mount or signal_delete_mount to
334
-	 * accommodate for additions/deletions in applicableUsers
335
-	 * and applicableGroups fields.
336
-	 *
337
-	 * @param StorageConfig $oldStorage old storage data
338
-	 * @param StorageConfig $newStorage new storage data
339
-	 */
340
-	abstract protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage);
341
-
342
-	/**
343
-	 * Update storage to the configuration
344
-	 *
345
-	 * @param StorageConfig $updatedStorage storage attributes
346
-	 *
347
-	 * @return StorageConfig storage config
348
-	 * @throws NotFoundException if the given storage does not exist in the config
349
-	 */
350
-	public function updateStorage(StorageConfig $updatedStorage) {
351
-		$id = $updatedStorage->getId();
352
-
353
-		$existingMount = $this->dbConfig->getMountById($id);
354
-
355
-		if (!is_array($existingMount)) {
356
-			throw new NotFoundException('Storage with ID "' . $id . '" not found while updating storage');
357
-		}
358
-
359
-		$oldStorage = $this->getStorageConfigFromDBMount($existingMount);
360
-
361
-		if ($oldStorage->getBackend() instanceof InvalidBackend) {
362
-			throw new NotFoundException('Storage with id "' . $id . '" cannot be edited due to missing backend');
363
-		}
364
-
365
-		$removedUsers = array_diff($oldStorage->getApplicableUsers(), $updatedStorage->getApplicableUsers());
366
-		$removedGroups = array_diff($oldStorage->getApplicableGroups(), $updatedStorage->getApplicableGroups());
367
-		$addedUsers = array_diff($updatedStorage->getApplicableUsers(), $oldStorage->getApplicableUsers());
368
-		$addedGroups = array_diff($updatedStorage->getApplicableGroups(), $oldStorage->getApplicableGroups());
369
-
370
-		$oldUserCount = count($oldStorage->getApplicableUsers());
371
-		$oldGroupCount = count($oldStorage->getApplicableGroups());
372
-		$newUserCount = count($updatedStorage->getApplicableUsers());
373
-		$newGroupCount = count($updatedStorage->getApplicableGroups());
374
-		$wasGlobal = ($oldUserCount + $oldGroupCount) === 0;
375
-		$isGlobal = ($newUserCount + $newGroupCount) === 0;
376
-
377
-		foreach ($removedUsers as $user) {
378
-			$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
379
-		}
380
-		foreach ($removedGroups as $group) {
381
-			$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
382
-		}
383
-		foreach ($addedUsers as $user) {
384
-			$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
385
-		}
386
-		foreach ($addedGroups as $group) {
387
-			$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
388
-		}
389
-
390
-		if ($wasGlobal && !$isGlobal) {
391
-			$this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
392
-		} elseif (!$wasGlobal && $isGlobal) {
393
-			$this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
394
-		}
395
-
396
-		$changedConfig = array_diff_assoc($updatedStorage->getBackendOptions(), $oldStorage->getBackendOptions());
397
-		$changedOptions = array_diff_assoc($updatedStorage->getMountOptions(), $oldStorage->getMountOptions());
398
-
399
-		foreach ($changedConfig as $key => $value) {
400
-			if ($value !== DefinitionParameter::UNMODIFIED_PLACEHOLDER) {
401
-				$this->dbConfig->setConfig($id, $key, $value);
402
-			}
403
-		}
404
-		foreach ($changedOptions as $key => $value) {
405
-			$this->dbConfig->setOption($id, $key, $value);
406
-		}
407
-
408
-		if ($updatedStorage->getMountPoint() !== $oldStorage->getMountPoint()) {
409
-			$this->dbConfig->setMountPoint($id, $updatedStorage->getMountPoint());
410
-		}
411
-
412
-		if ($updatedStorage->getAuthMechanism()->getIdentifier() !== $oldStorage->getAuthMechanism()->getIdentifier()) {
413
-			$this->dbConfig->setAuthBackend($id, $updatedStorage->getAuthMechanism()->getIdentifier());
414
-		}
415
-
416
-		$this->triggerChangeHooks($oldStorage, $updatedStorage);
417
-
418
-		if (($wasGlobal && !$isGlobal) || count($removedGroups) > 0) { // to expensive to properly handle these on the fly
419
-			$this->userMountCache->remoteStorageMounts($this->getStorageId($updatedStorage));
420
-		} else {
421
-			$storageId = $this->getStorageId($updatedStorage);
422
-			foreach ($removedUsers as $userId) {
423
-				$this->userMountCache->removeUserStorageMount($storageId, $userId);
424
-			}
425
-		}
426
-
427
-		return $this->getStorage($id);
428
-	}
429
-
430
-	/**
431
-	 * Delete the storage with the given id.
432
-	 *
433
-	 * @param int $id storage id
434
-	 *
435
-	 * @throws NotFoundException if no storage was found with the given id
436
-	 */
437
-	public function removeStorage(int $id) {
438
-		$existingMount = $this->dbConfig->getMountById($id);
439
-
440
-		if (!is_array($existingMount)) {
441
-			throw new NotFoundException('Storage with ID "' . $id . '" not found');
442
-		}
443
-
444
-		$this->dbConfig->removeMount($id);
445
-
446
-		$deletedStorage = $this->getStorageConfigFromDBMount($existingMount);
447
-		$this->triggerHooks($deletedStorage, Filesystem::signal_delete_mount);
448
-
449
-		// delete oc_storages entries and oc_filecache
450
-		Storage::cleanByMountId($id);
451
-	}
452
-
453
-	/**
454
-	 * Construct the storage implementation
455
-	 *
456
-	 * @param StorageConfig $storageConfig
457
-	 * @return int
458
-	 */
459
-	private function getStorageId(StorageConfig $storageConfig) {
460
-		try {
461
-			$class = $storageConfig->getBackend()->getStorageClass();
462
-			/** @var \OC\Files\Storage\Storage $storage */
463
-			$storage = new $class($storageConfig->getBackendOptions());
464
-
465
-			// auth mechanism should fire first
466
-			$storage = $storageConfig->getBackend()->wrapStorage($storage);
467
-			$storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
468
-
469
-			/** @var \OC\Files\Storage\Storage $storage */
470
-			return $storage->getStorageCache()->getNumericId();
471
-		} catch (\Exception $e) {
472
-			return -1;
473
-		}
474
-	}
31
+    /**
32
+     * @param BackendService $backendService
33
+     * @param DBConfigService $dbConfig
34
+     * @param IUserMountCache $userMountCache
35
+     * @param IEventDispatcher $eventDispatcher
36
+     */
37
+    public function __construct(
38
+        protected BackendService $backendService,
39
+        protected DBConfigService $dbConfig,
40
+        protected IUserMountCache $userMountCache,
41
+        protected IEventDispatcher $eventDispatcher,
42
+    ) {
43
+    }
44
+
45
+    protected function readDBConfig() {
46
+        return $this->dbConfig->getAdminMounts();
47
+    }
48
+
49
+    protected function getStorageConfigFromDBMount(array $mount) {
50
+        $applicableUsers = array_filter($mount['applicable'], function ($applicable) {
51
+            return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_USER;
52
+        });
53
+        $applicableUsers = array_map(function ($applicable) {
54
+            return $applicable['value'];
55
+        }, $applicableUsers);
56
+
57
+        $applicableGroups = array_filter($mount['applicable'], function ($applicable) {
58
+            return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_GROUP;
59
+        });
60
+        $applicableGroups = array_map(function ($applicable) {
61
+            return $applicable['value'];
62
+        }, $applicableGroups);
63
+
64
+        try {
65
+            $config = $this->createStorage(
66
+                $mount['mount_point'],
67
+                $mount['storage_backend'],
68
+                $mount['auth_backend'],
69
+                $mount['config'],
70
+                $mount['options'],
71
+                array_values($applicableUsers),
72
+                array_values($applicableGroups),
73
+                $mount['priority']
74
+            );
75
+            $config->setType($mount['type']);
76
+            $config->setId((int)$mount['mount_id']);
77
+            return $config;
78
+        } catch (\UnexpectedValueException $e) {
79
+            // don't die if a storage backend doesn't exist
80
+            Server::get(LoggerInterface::class)->error('Could not load storage.', [
81
+                'app' => 'files_external',
82
+                'exception' => $e,
83
+            ]);
84
+            return null;
85
+        } catch (\InvalidArgumentException $e) {
86
+            Server::get(LoggerInterface::class)->error('Could not load storage.', [
87
+                'app' => 'files_external',
88
+                'exception' => $e,
89
+            ]);
90
+            return null;
91
+        }
92
+    }
93
+
94
+    /**
95
+     * Read the external storage config
96
+     *
97
+     * @return array map of storage id to storage config
98
+     */
99
+    protected function readConfig() {
100
+        $mounts = $this->readDBConfig();
101
+        $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
102
+        $configs = array_filter($configs, function ($config) {
103
+            return $config instanceof StorageConfig;
104
+        });
105
+
106
+        $keys = array_map(function (StorageConfig $config) {
107
+            return $config->getId();
108
+        }, $configs);
109
+
110
+        return array_combine($keys, $configs);
111
+    }
112
+
113
+    /**
114
+     * Get a storage with status
115
+     *
116
+     * @param int $id storage id
117
+     *
118
+     * @return StorageConfig
119
+     * @throws NotFoundException if the storage with the given id was not found
120
+     */
121
+    public function getStorage(int $id) {
122
+        $mount = $this->dbConfig->getMountById($id);
123
+
124
+        if (!is_array($mount)) {
125
+            throw new NotFoundException('Storage with ID "' . $id . '" not found');
126
+        }
127
+
128
+        $config = $this->getStorageConfigFromDBMount($mount);
129
+        if ($this->isApplicable($config)) {
130
+            return $config;
131
+        } else {
132
+            throw new NotFoundException('Storage with ID "' . $id . '" not found');
133
+        }
134
+    }
135
+
136
+    /**
137
+     * Check whether this storage service should provide access to a storage
138
+     *
139
+     * @param StorageConfig $config
140
+     * @return bool
141
+     */
142
+    abstract protected function isApplicable(StorageConfig $config);
143
+
144
+    /**
145
+     * Gets all storages, valid or not
146
+     *
147
+     * @return StorageConfig[] array of storage configs
148
+     */
149
+    public function getAllStorages() {
150
+        return $this->readConfig();
151
+    }
152
+
153
+    /**
154
+     * Gets all valid storages
155
+     *
156
+     * @return StorageConfig[]
157
+     */
158
+    public function getStorages() {
159
+        return array_filter($this->getAllStorages(), [$this, 'validateStorage']);
160
+    }
161
+
162
+    /**
163
+     * Validate storage
164
+     * FIXME: De-duplicate with StoragesController::validate()
165
+     *
166
+     * @param StorageConfig $storage
167
+     * @return bool
168
+     */
169
+    protected function validateStorage(StorageConfig $storage) {
170
+        /** @var Backend */
171
+        $backend = $storage->getBackend();
172
+        /** @var AuthMechanism */
173
+        $authMechanism = $storage->getAuthMechanism();
174
+
175
+        if (!$backend->isVisibleFor($this->getVisibilityType())) {
176
+            // not permitted to use backend
177
+            return false;
178
+        }
179
+        if (!$authMechanism->isVisibleFor($this->getVisibilityType())) {
180
+            // not permitted to use auth mechanism
181
+            return false;
182
+        }
183
+
184
+        return true;
185
+    }
186
+
187
+    /**
188
+     * Get the visibility type for this controller, used in validation
189
+     *
190
+     * @return int BackendService::VISIBILITY_* constants
191
+     */
192
+    abstract public function getVisibilityType();
193
+
194
+    /**
195
+     * @return integer
196
+     */
197
+    protected function getType() {
198
+        return DBConfigService::MOUNT_TYPE_ADMIN;
199
+    }
200
+
201
+    /**
202
+     * Add new storage to the configuration
203
+     *
204
+     * @param StorageConfig $newStorage storage attributes
205
+     *
206
+     * @return StorageConfig storage config, with added id
207
+     */
208
+    public function addStorage(StorageConfig $newStorage) {
209
+        $allStorages = $this->readConfig();
210
+
211
+        $configId = $this->dbConfig->addMount(
212
+            $newStorage->getMountPoint(),
213
+            $newStorage->getBackend()->getIdentifier(),
214
+            $newStorage->getAuthMechanism()->getIdentifier(),
215
+            $newStorage->getPriority(),
216
+            $this->getType()
217
+        );
218
+
219
+        $newStorage->setId($configId);
220
+
221
+        foreach ($newStorage->getApplicableUsers() as $user) {
222
+            $this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_USER, $user);
223
+        }
224
+        foreach ($newStorage->getApplicableGroups() as $group) {
225
+            $this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
226
+        }
227
+        foreach ($newStorage->getBackendOptions() as $key => $value) {
228
+            $this->dbConfig->setConfig($configId, $key, $value);
229
+        }
230
+        foreach ($newStorage->getMountOptions() as $key => $value) {
231
+            $this->dbConfig->setOption($configId, $key, $value);
232
+        }
233
+
234
+        if (count($newStorage->getApplicableUsers()) === 0 && count($newStorage->getApplicableGroups()) === 0) {
235
+            $this->dbConfig->addApplicable($configId, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
236
+        }
237
+
238
+        // add new storage
239
+        $allStorages[$configId] = $newStorage;
240
+
241
+        $this->triggerHooks($newStorage, Filesystem::signal_create_mount);
242
+
243
+        $newStorage->setStatus(StorageNotAvailableException::STATUS_SUCCESS);
244
+        return $newStorage;
245
+    }
246
+
247
+    /**
248
+     * Create a storage from its parameters
249
+     *
250
+     * @param string $mountPoint storage mount point
251
+     * @param string $backendIdentifier backend identifier
252
+     * @param string $authMechanismIdentifier authentication mechanism identifier
253
+     * @param array $backendOptions backend-specific options
254
+     * @param array|null $mountOptions mount-specific options
255
+     * @param array|null $applicableUsers users for which to mount the storage
256
+     * @param array|null $applicableGroups groups for which to mount the storage
257
+     * @param int|null $priority priority
258
+     *
259
+     * @return StorageConfig
260
+     */
261
+    public function createStorage(
262
+        $mountPoint,
263
+        $backendIdentifier,
264
+        $authMechanismIdentifier,
265
+        $backendOptions,
266
+        $mountOptions = null,
267
+        $applicableUsers = null,
268
+        $applicableGroups = null,
269
+        $priority = null,
270
+    ) {
271
+        $backend = $this->backendService->getBackend($backendIdentifier);
272
+        if (!$backend) {
273
+            $backend = new InvalidBackend($backendIdentifier);
274
+        }
275
+        $authMechanism = $this->backendService->getAuthMechanism($authMechanismIdentifier);
276
+        if (!$authMechanism) {
277
+            $authMechanism = new InvalidAuth($authMechanismIdentifier);
278
+        }
279
+        $newStorage = new StorageConfig();
280
+        $newStorage->setMountPoint($mountPoint);
281
+        $newStorage->setBackend($backend);
282
+        $newStorage->setAuthMechanism($authMechanism);
283
+        $newStorage->setBackendOptions($backendOptions);
284
+        if (isset($mountOptions)) {
285
+            $newStorage->setMountOptions($mountOptions);
286
+        }
287
+        if (isset($applicableUsers)) {
288
+            $newStorage->setApplicableUsers($applicableUsers);
289
+        }
290
+        if (isset($applicableGroups)) {
291
+            $newStorage->setApplicableGroups($applicableGroups);
292
+        }
293
+        if (isset($priority)) {
294
+            $newStorage->setPriority($priority);
295
+        }
296
+
297
+        return $newStorage;
298
+    }
299
+
300
+    /**
301
+     * Triggers the given hook signal for all the applicables given
302
+     *
303
+     * @param string $signal signal
304
+     * @param string $mountPoint hook mount point param
305
+     * @param string $mountType hook mount type param
306
+     * @param array $applicableArray array of applicable users/groups for which to trigger the hook
307
+     */
308
+    protected function triggerApplicableHooks($signal, $mountPoint, $mountType, $applicableArray): void {
309
+        $this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent(null));
310
+        foreach ($applicableArray as $applicable) {
311
+            Util::emitHook(
312
+                Filesystem::CLASSNAME,
313
+                $signal,
314
+                [
315
+                    Filesystem::signal_param_path => $mountPoint,
316
+                    Filesystem::signal_param_mount_type => $mountType,
317
+                    Filesystem::signal_param_users => $applicable,
318
+                ]
319
+            );
320
+        }
321
+    }
322
+
323
+    /**
324
+     * Triggers $signal for all applicable users of the given
325
+     * storage
326
+     *
327
+     * @param StorageConfig $storage storage data
328
+     * @param string $signal signal to trigger
329
+     */
330
+    abstract protected function triggerHooks(StorageConfig $storage, $signal);
331
+
332
+    /**
333
+     * Triggers signal_create_mount or signal_delete_mount to
334
+     * accommodate for additions/deletions in applicableUsers
335
+     * and applicableGroups fields.
336
+     *
337
+     * @param StorageConfig $oldStorage old storage data
338
+     * @param StorageConfig $newStorage new storage data
339
+     */
340
+    abstract protected function triggerChangeHooks(StorageConfig $oldStorage, StorageConfig $newStorage);
341
+
342
+    /**
343
+     * Update storage to the configuration
344
+     *
345
+     * @param StorageConfig $updatedStorage storage attributes
346
+     *
347
+     * @return StorageConfig storage config
348
+     * @throws NotFoundException if the given storage does not exist in the config
349
+     */
350
+    public function updateStorage(StorageConfig $updatedStorage) {
351
+        $id = $updatedStorage->getId();
352
+
353
+        $existingMount = $this->dbConfig->getMountById($id);
354
+
355
+        if (!is_array($existingMount)) {
356
+            throw new NotFoundException('Storage with ID "' . $id . '" not found while updating storage');
357
+        }
358
+
359
+        $oldStorage = $this->getStorageConfigFromDBMount($existingMount);
360
+
361
+        if ($oldStorage->getBackend() instanceof InvalidBackend) {
362
+            throw new NotFoundException('Storage with id "' . $id . '" cannot be edited due to missing backend');
363
+        }
364
+
365
+        $removedUsers = array_diff($oldStorage->getApplicableUsers(), $updatedStorage->getApplicableUsers());
366
+        $removedGroups = array_diff($oldStorage->getApplicableGroups(), $updatedStorage->getApplicableGroups());
367
+        $addedUsers = array_diff($updatedStorage->getApplicableUsers(), $oldStorage->getApplicableUsers());
368
+        $addedGroups = array_diff($updatedStorage->getApplicableGroups(), $oldStorage->getApplicableGroups());
369
+
370
+        $oldUserCount = count($oldStorage->getApplicableUsers());
371
+        $oldGroupCount = count($oldStorage->getApplicableGroups());
372
+        $newUserCount = count($updatedStorage->getApplicableUsers());
373
+        $newGroupCount = count($updatedStorage->getApplicableGroups());
374
+        $wasGlobal = ($oldUserCount + $oldGroupCount) === 0;
375
+        $isGlobal = ($newUserCount + $newGroupCount) === 0;
376
+
377
+        foreach ($removedUsers as $user) {
378
+            $this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
379
+        }
380
+        foreach ($removedGroups as $group) {
381
+            $this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
382
+        }
383
+        foreach ($addedUsers as $user) {
384
+            $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
385
+        }
386
+        foreach ($addedGroups as $group) {
387
+            $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
388
+        }
389
+
390
+        if ($wasGlobal && !$isGlobal) {
391
+            $this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
392
+        } elseif (!$wasGlobal && $isGlobal) {
393
+            $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
394
+        }
395
+
396
+        $changedConfig = array_diff_assoc($updatedStorage->getBackendOptions(), $oldStorage->getBackendOptions());
397
+        $changedOptions = array_diff_assoc($updatedStorage->getMountOptions(), $oldStorage->getMountOptions());
398
+
399
+        foreach ($changedConfig as $key => $value) {
400
+            if ($value !== DefinitionParameter::UNMODIFIED_PLACEHOLDER) {
401
+                $this->dbConfig->setConfig($id, $key, $value);
402
+            }
403
+        }
404
+        foreach ($changedOptions as $key => $value) {
405
+            $this->dbConfig->setOption($id, $key, $value);
406
+        }
407
+
408
+        if ($updatedStorage->getMountPoint() !== $oldStorage->getMountPoint()) {
409
+            $this->dbConfig->setMountPoint($id, $updatedStorage->getMountPoint());
410
+        }
411
+
412
+        if ($updatedStorage->getAuthMechanism()->getIdentifier() !== $oldStorage->getAuthMechanism()->getIdentifier()) {
413
+            $this->dbConfig->setAuthBackend($id, $updatedStorage->getAuthMechanism()->getIdentifier());
414
+        }
415
+
416
+        $this->triggerChangeHooks($oldStorage, $updatedStorage);
417
+
418
+        if (($wasGlobal && !$isGlobal) || count($removedGroups) > 0) { // to expensive to properly handle these on the fly
419
+            $this->userMountCache->remoteStorageMounts($this->getStorageId($updatedStorage));
420
+        } else {
421
+            $storageId = $this->getStorageId($updatedStorage);
422
+            foreach ($removedUsers as $userId) {
423
+                $this->userMountCache->removeUserStorageMount($storageId, $userId);
424
+            }
425
+        }
426
+
427
+        return $this->getStorage($id);
428
+    }
429
+
430
+    /**
431
+     * Delete the storage with the given id.
432
+     *
433
+     * @param int $id storage id
434
+     *
435
+     * @throws NotFoundException if no storage was found with the given id
436
+     */
437
+    public function removeStorage(int $id) {
438
+        $existingMount = $this->dbConfig->getMountById($id);
439
+
440
+        if (!is_array($existingMount)) {
441
+            throw new NotFoundException('Storage with ID "' . $id . '" not found');
442
+        }
443
+
444
+        $this->dbConfig->removeMount($id);
445
+
446
+        $deletedStorage = $this->getStorageConfigFromDBMount($existingMount);
447
+        $this->triggerHooks($deletedStorage, Filesystem::signal_delete_mount);
448
+
449
+        // delete oc_storages entries and oc_filecache
450
+        Storage::cleanByMountId($id);
451
+    }
452
+
453
+    /**
454
+     * Construct the storage implementation
455
+     *
456
+     * @param StorageConfig $storageConfig
457
+     * @return int
458
+     */
459
+    private function getStorageId(StorageConfig $storageConfig) {
460
+        try {
461
+            $class = $storageConfig->getBackend()->getStorageClass();
462
+            /** @var \OC\Files\Storage\Storage $storage */
463
+            $storage = new $class($storageConfig->getBackendOptions());
464
+
465
+            // auth mechanism should fire first
466
+            $storage = $storageConfig->getBackend()->wrapStorage($storage);
467
+            $storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
468
+
469
+            /** @var \OC\Files\Storage\Storage $storage */
470
+            return $storage->getStorageCache()->getNumericId();
471
+        } catch (\Exception $e) {
472
+            return -1;
473
+        }
474
+    }
475 475
 }
Please login to merge, or discard this patch.
private/AppFramework/Middleware/Security/Exceptions/NotAdminException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
  * @package OC\AppFramework\Middleware\Security\Exceptions
37 37
  */
38 38
 class NotAdminException extends SecurityException {
39
-	public function __construct(string $message) {
40
-		parent::__construct($message, Http::STATUS_FORBIDDEN);
41
-	}
39
+    public function __construct(string $message) {
40
+        parent::__construct($message, Http::STATUS_FORBIDDEN);
41
+    }
42 42
 }
Please login to merge, or discard this patch.
apps/dav/lib/Upload/ChunkingPlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
 
101 101
 		// casted to string because cast to float cause equality for non equal numbers
102 102
 		// and integer has the problem of limited size on 32 bit systems
103
-		if ((string)$expectedSize !== (string)$actualSize) {
103
+		if ((string) $expectedSize !== (string) $actualSize) {
104 104
 			throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes");
105 105
 		}
106 106
 	}
Please login to merge, or discard this patch.
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -18,97 +18,97 @@
 block discarded – undo
18 18
 
19 19
 class ChunkingPlugin extends ServerPlugin {
20 20
 
21
-	/** @var Server */
22
-	private $server;
23
-	/** @var FutureFile */
24
-	private $sourceNode;
21
+    /** @var Server */
22
+    private $server;
23
+    /** @var FutureFile */
24
+    private $sourceNode;
25 25
 
26
-	/**
27
-	 * @inheritdoc
28
-	 */
29
-	public function initialize(Server $server) {
30
-		$server->on('beforeMove', [$this, 'beforeMove']);
31
-		$this->server = $server;
32
-	}
26
+    /**
27
+     * @inheritdoc
28
+     */
29
+    public function initialize(Server $server) {
30
+        $server->on('beforeMove', [$this, 'beforeMove']);
31
+        $this->server = $server;
32
+    }
33 33
 
34
-	/**
35
-	 * @param string $sourcePath source path
36
-	 * @param string $destination destination path
37
-	 * @return bool|void
38
-	 * @throws BadRequest
39
-	 * @throws NotFound
40
-	 */
41
-	public function beforeMove($sourcePath, $destination) {
42
-		$this->sourceNode = $this->server->tree->getNodeForPath($sourcePath);
43
-		if (!$this->sourceNode instanceof FutureFile) {
44
-			// skip handling as the source is not a chunked FutureFile
45
-			return;
46
-		}
34
+    /**
35
+     * @param string $sourcePath source path
36
+     * @param string $destination destination path
37
+     * @return bool|void
38
+     * @throws BadRequest
39
+     * @throws NotFound
40
+     */
41
+    public function beforeMove($sourcePath, $destination) {
42
+        $this->sourceNode = $this->server->tree->getNodeForPath($sourcePath);
43
+        if (!$this->sourceNode instanceof FutureFile) {
44
+            // skip handling as the source is not a chunked FutureFile
45
+            return;
46
+        }
47 47
 
48
-		try {
49
-			/** @var INode $destinationNode */
50
-			$destinationNode = $this->server->tree->getNodeForPath($destination);
51
-			if ($destinationNode instanceof Directory) {
52
-				throw new BadRequest("The given destination $destination is a directory.");
53
-			}
54
-		} catch (NotFound $e) {
55
-			// If the destination does not exist yet it's not a directory either ;)
56
-		}
48
+        try {
49
+            /** @var INode $destinationNode */
50
+            $destinationNode = $this->server->tree->getNodeForPath($destination);
51
+            if ($destinationNode instanceof Directory) {
52
+                throw new BadRequest("The given destination $destination is a directory.");
53
+            }
54
+        } catch (NotFound $e) {
55
+            // If the destination does not exist yet it's not a directory either ;)
56
+        }
57 57
 
58
-		$this->verifySize();
59
-		return $this->performMove($sourcePath, $destination);
60
-	}
58
+        $this->verifySize();
59
+        return $this->performMove($sourcePath, $destination);
60
+    }
61 61
 
62
-	/**
63
-	 * Move handler for future file.
64
-	 *
65
-	 * This overrides the default move behavior to prevent Sabre
66
-	 * to delete the target file before moving. Because deleting would
67
-	 * lose the file id and metadata.
68
-	 *
69
-	 * @param string $path source path
70
-	 * @param string $destination destination path
71
-	 * @return bool|void false to stop handling, void to skip this handler
72
-	 */
73
-	public function performMove($path, $destination) {
74
-		$fileExists = $this->server->tree->nodeExists($destination);
75
-		// do a move manually, skipping Sabre's default "delete" for existing nodes
76
-		try {
77
-			$this->server->tree->move($path, $destination);
78
-		} catch (Forbidden $e) {
79
-			$sourceNode = $this->server->tree->getNodeForPath($path);
80
-			if ($sourceNode instanceof FutureFile) {
81
-				$sourceNode->delete();
82
-			}
83
-			throw $e;
84
-		}
62
+    /**
63
+     * Move handler for future file.
64
+     *
65
+     * This overrides the default move behavior to prevent Sabre
66
+     * to delete the target file before moving. Because deleting would
67
+     * lose the file id and metadata.
68
+     *
69
+     * @param string $path source path
70
+     * @param string $destination destination path
71
+     * @return bool|void false to stop handling, void to skip this handler
72
+     */
73
+    public function performMove($path, $destination) {
74
+        $fileExists = $this->server->tree->nodeExists($destination);
75
+        // do a move manually, skipping Sabre's default "delete" for existing nodes
76
+        try {
77
+            $this->server->tree->move($path, $destination);
78
+        } catch (Forbidden $e) {
79
+            $sourceNode = $this->server->tree->getNodeForPath($path);
80
+            if ($sourceNode instanceof FutureFile) {
81
+                $sourceNode->delete();
82
+            }
83
+            throw $e;
84
+        }
85 85
 
86
-		// trigger all default events (copied from CorePlugin::move)
87
-		$this->server->emit('afterMove', [$path, $destination]);
88
-		$this->server->emit('afterUnbind', [$path]);
89
-		$this->server->emit('afterBind', [$destination]);
86
+        // trigger all default events (copied from CorePlugin::move)
87
+        $this->server->emit('afterMove', [$path, $destination]);
88
+        $this->server->emit('afterUnbind', [$path]);
89
+        $this->server->emit('afterBind', [$destination]);
90 90
 
91
-		$response = $this->server->httpResponse;
92
-		$response->setHeader('Content-Length', '0');
93
-		$response->setStatus($fileExists ? Http::STATUS_NO_CONTENT : Http::STATUS_CREATED);
91
+        $response = $this->server->httpResponse;
92
+        $response->setHeader('Content-Length', '0');
93
+        $response->setStatus($fileExists ? Http::STATUS_NO_CONTENT : Http::STATUS_CREATED);
94 94
 
95
-		return false;
96
-	}
95
+        return false;
96
+    }
97 97
 
98
-	/**
99
-	 * @throws BadRequest
100
-	 */
101
-	private function verifySize() {
102
-		$expectedSize = $this->server->httpRequest->getHeader('OC-Total-Length');
103
-		if ($expectedSize === null) {
104
-			return;
105
-		}
106
-		$actualSize = $this->sourceNode->getSize();
98
+    /**
99
+     * @throws BadRequest
100
+     */
101
+    private function verifySize() {
102
+        $expectedSize = $this->server->httpRequest->getHeader('OC-Total-Length');
103
+        if ($expectedSize === null) {
104
+            return;
105
+        }
106
+        $actualSize = $this->sourceNode->getSize();
107 107
 
108
-		// casted to string because cast to float cause equality for non equal numbers
109
-		// and integer has the problem of limited size on 32 bit systems
110
-		if ((string)$expectedSize !== (string)$actualSize) {
111
-			throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes");
112
-		}
113
-	}
108
+        // casted to string because cast to float cause equality for non equal numbers
109
+        // and integer has the problem of limited size on 32 bit systems
110
+        if ((string)$expectedSize !== (string)$actualSize) {
111
+            throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize bytes");
112
+        }
113
+    }
114 114
 }
Please login to merge, or discard this patch.
core/Migrations/Version14000Date20180129121024.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,30 +30,30 @@
 block discarded – undo
30 30
  * Delete the admin|personal sections and settings tables
31 31
  */
32 32
 class Version14000Date20180129121024 extends SimpleMigrationStep {
33
-	public function name(): string {
34
-		return 'Drop obsolete settings tables';
35
-	}
33
+    public function name(): string {
34
+        return 'Drop obsolete settings tables';
35
+    }
36 36
 
37
-	public function description(): string {
38
-		return 'Drops the following obsolete tables: "admin_sections", "admin_settings", "personal_sections" and "personal_settings"';
39
-	}
37
+    public function description(): string {
38
+        return 'Drops the following obsolete tables: "admin_sections", "admin_settings", "personal_sections" and "personal_settings"';
39
+    }
40 40
 
41
-	/**
42
-	 * @param IOutput $output
43
-	 * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
44
-	 * @param array $options
45
-	 * @return null|ISchemaWrapper
46
-	 * @since 13.0.0
47
-	 */
48
-	public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
49
-		/** @var ISchemaWrapper $schema */
50
-		$schema = $schemaClosure();
41
+    /**
42
+     * @param IOutput $output
43
+     * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
44
+     * @param array $options
45
+     * @return null|ISchemaWrapper
46
+     * @since 13.0.0
47
+     */
48
+    public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
49
+        /** @var ISchemaWrapper $schema */
50
+        $schema = $schemaClosure();
51 51
 
52
-		$schema->dropTable('admin_sections');
53
-		$schema->dropTable('admin_settings');
54
-		$schema->dropTable('personal_sections');
55
-		$schema->dropTable('personal_settings');
52
+        $schema->dropTable('admin_sections');
53
+        $schema->dropTable('admin_settings');
54
+        $schema->dropTable('personal_sections');
55
+        $schema->dropTable('personal_settings');
56 56
 
57
-		return $schema;
58
-	}
57
+        return $schema;
58
+    }
59 59
 }
Please login to merge, or discard this patch.
apps/dav/lib/Direct/Server.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@
 block discarded – undo
25 25
 namespace OCA\DAV\Direct;
26 26
 
27 27
 class Server extends \Sabre\DAV\Server {
28
-	public function __construct($treeOrNode = null) {
29
-		parent::__construct($treeOrNode);
30
-		self::$exposeVersion = false;
31
-		$this->enablePropfindDepthInfinityf = false;
32
-	}
28
+    public function __construct($treeOrNode = null) {
29
+        parent::__construct($treeOrNode);
30
+        self::$exposeVersion = false;
31
+        $this->enablePropfindDepthInfinityf = false;
32
+    }
33 33
 }
Please login to merge, or discard this patch.