Passed
Push — master ( 54f366...417f46 )
by Blizzz
15:08 queued 13s
created
lib/private/Files/SetupManager.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 		OC_App::loadApps(['filesystem']);
132 132
 		$prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false);
133 133
 
134
-		Filesystem::addStorageWrapper('mount_options', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
134
+		Filesystem::addStorageWrapper('mount_options', function($mountPoint, IStorage $storage, IMountPoint $mount) {
135 135
 			if ($storage->instanceOfStorage(Common::class)) {
136 136
 				$storage->setMountOptions($mount->getOptions());
137 137
 			}
138 138
 			return $storage;
139 139
 		});
140 140
 
141
-		Filesystem::addStorageWrapper('enable_sharing', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
141
+		Filesystem::addStorageWrapper('enable_sharing', function($mountPoint, IStorage $storage, IMountPoint $mount) {
142 142
 			if (!$mount->getOption('enable_sharing', true)) {
143 143
 				return new PermissionsMask([
144 144
 					'storage' => $storage,
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
 		});
150 150
 
151 151
 		// install storage availability wrapper, before most other wrappers
152
-		Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, IStorage $storage) {
152
+		Filesystem::addStorageWrapper('oc_availability', function($mountPoint, IStorage $storage) {
153 153
 			if (!$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) {
154 154
 				return new Availability(['storage' => $storage]);
155 155
 			}
156 156
 			return $storage;
157 157
 		});
158 158
 
159
-		Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
159
+		Filesystem::addStorageWrapper('oc_encoding', function($mountPoint, IStorage $storage, IMountPoint $mount) {
160 160
 			if ($mount->getOption('encoding_compatibility', false) && !$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
161 161
 				return new Encoding(['storage' => $storage]);
162 162
 			}
163 163
 			return $storage;
164 164
 		});
165 165
 
166
-		Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) {
166
+		Filesystem::addStorageWrapper('oc_quota', function($mountPoint, $storage) {
167 167
 			// set up quota for home storages, even for other users
168 168
 			// which can happen when using sharing
169 169
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			if ($storage->instanceOfStorage(HomeObjectStoreStorage::class) || $storage->instanceOfStorage(Home::class)) {
174 174
 				if (is_object($storage->getUser())) {
175 175
 					$user = $storage->getUser();
176
-					return new Quota(['storage' => $storage, 'quotaCallback' => function () use ($user) {
176
+					return new Quota(['storage' => $storage, 'quotaCallback' => function() use ($user) {
177 177
 						return OC_Util::getUserQuota($user);
178 178
 					}, 'root' => 'files']);
179 179
 				}
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			return $storage;
183 183
 		});
184 184
 
185
-		Filesystem::addStorageWrapper('readonly', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
185
+		Filesystem::addStorageWrapper('readonly', function($mountPoint, IStorage $storage, IMountPoint $mount) {
186 186
 			/*
187 187
 			 * Do not allow any operations that modify the storage
188 188
 			 */
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$previouslySetupProviders = $this->setupUserMountProviders[$user->getUID()];
219 219
 
220
-		$this->setupForUserWith($user, function () use ($user) {
221
-			$this->mountProviderCollection->addMountForUser($user, $this->mountManager, function (
220
+		$this->setupForUserWith($user, function() use ($user) {
221
+			$this->mountProviderCollection->addMountForUser($user, $this->mountManager, function(
222 222
 				IMountProvider $provider
223 223
 			) use ($user) {
224 224
 				return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 		Filesystem::logWarningWhenAddingStorageWrapper($prevLogging);
246 246
 
247
-		$userDir = '/' . $user->getUID() . '/files';
247
+		$userDir = '/'.$user->getUID().'/files';
248 248
 
249 249
 		Filesystem::initInternal($userDir);
250 250
 
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 		} else {
261 261
 			$this->mountManager->addMount(new MountPoint(
262 262
 				new NullStorage([]),
263
-				'/' . $user->getUID()
263
+				'/'.$user->getUID()
264 264
 			));
265 265
 			$this->mountManager->addMount(new MountPoint(
266 266
 				new NullStorage([]),
267
-				'/' . $user->getUID() . '/files'
267
+				'/'.$user->getUID().'/files'
268 268
 			));
269 269
 			$this->setupUsersComplete[] = $user->getUID();
270 270
 		}
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
 	 * Final housekeeping after a user has been fully setup
277 277
 	 */
278 278
 	private function afterUserFullySetup(IUser $user, array $previouslySetupProviders): void {
279
-		$userRoot = '/' . $user->getUID() . '/';
279
+		$userRoot = '/'.$user->getUID().'/';
280 280
 		$mounts = $this->mountManager->getAll();
281
-		$mounts = array_filter($mounts, function (IMountPoint $mount) use ($userRoot) {
281
+		$mounts = array_filter($mounts, function(IMountPoint $mount) use ($userRoot) {
282 282
 			return strpos($mount->getMountPoint(), $userRoot) === 0;
283 283
 		});
284
-		$allProviders = array_map(function (IMountProvider $provider) {
284
+		$allProviders = array_map(function(IMountProvider $provider) {
285 285
 			return get_class($provider);
286 286
 		}, $this->mountProviderCollection->getProviders());
287 287
 		$newProviders = array_diff($allProviders, $previouslySetupProviders);
288
-		$mounts = array_filter($mounts, function (IMountPoint $mount) use ($previouslySetupProviders) {
288
+		$mounts = array_filter($mounts, function(IMountPoint $mount) use ($previouslySetupProviders) {
289 289
 			return !in_array($mount->getMountProvider(), $previouslySetupProviders);
290 290
 		});
291 291
 		$this->userMountCache->registerMounts($user, $mounts, $newProviders);
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 		}
319 319
 		\OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', ['user' => $user->getUID()]);
320 320
 
321
-		$userDir = '/' . $user->getUID() . '/files';
321
+		$userDir = '/'.$user->getUID().'/files';
322 322
 		OC_Hook::emit('OC_Filesystem', 'setup', ['user' => $user->getUID(), 'user_dir' => $userDir]);
323 323
 
324 324
 		$this->eventLogger->end('setup_fs');
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 			} else {
362 362
 				return null;
363 363
 			}
364
-		} elseif (strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
364
+		} elseif (strpos($path, '/appdata_'.\OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
365 365
 			return null;
366 366
 		} else {
367 367
 			[, $userId] = explode('/', $path);
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 		}
391 391
 
392 392
 		// for the user's home folder, and includes children we need everything always
393
-		if (rtrim($path) === "/" . $user->getUID() . "/files" && $includeChildren) {
393
+		if (rtrim($path) === "/".$user->getUID()."/files" && $includeChildren) {
394 394
 			$this->setupForUser($user);
395 395
 			return;
396 396
 		}
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 			if ($cachedMount->getMountProvider()) {
420 420
 				$mounts = $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]);
421 421
 			} else {
422
-				$this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
422
+				$this->logger->debug("mount at ".$cachedMount->getMountPoint()." has no provider set, performing full setup");
423 423
 				$this->setupForUser($user);
424 424
 				return;
425 425
 			}
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 					if ($cachedMount->getMountProvider()) {
435 435
 						$mounts = array_merge($mounts, $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]));
436 436
 					} else {
437
-						$this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
437
+						$this->logger->debug("mount at ".$cachedMount->getMountPoint()." has no provider set, performing full setup");
438 438
 						$this->setupForUser($user);
439 439
 						return;
440 440
 					}
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
 		if (count($mounts)) {
446 446
 			$this->userMountCache->registerMounts($user, $mounts, $currentProviders);
447
-			$this->setupForUserWith($user, function () use ($mounts) {
447
+			$this->setupForUserWith($user, function() use ($mounts) {
448 448
 				array_walk($mounts, [$this->mountManager, 'addMount']);
449 449
 			});
450 450
 		} elseif (!$this->isSetupStarted($user)) {
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		}
484 484
 
485 485
 		// home providers are always used
486
-		$providers = array_filter($providers, function (string $provider) {
486
+		$providers = array_filter($providers, function(string $provider) {
487 487
 			return !is_subclass_of($provider, IHomeMountProvider::class);
488 488
 		});
489 489
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 		}
506 506
 
507 507
 		$this->userMountCache->registerMounts($user, $mounts, $providers);
508
-		$this->setupForUserWith($user, function () use ($mounts) {
508
+		$this->setupForUserWith($user, function() use ($mounts) {
509 509
 			array_walk($mounts, [$this->mountManager, 'addMount']);
510 510
 		});
511 511
 	}
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	private function listenForNewMountProviders() {
527 527
 		if (!$this->listeningForProviders) {
528 528
 			$this->listeningForProviders = true;
529
-			$this->mountProviderCollection->listen('\OC\Files\Config', 'registerMountProvider', function (
529
+			$this->mountProviderCollection->listen('\OC\Files\Config', 'registerMountProvider', function(
530 530
 				IMountProvider $provider
531 531
 			) {
532 532
 				foreach ($this->setupUsers as $userId) {
@@ -544,16 +544,16 @@  discard block
 block discarded – undo
544 544
 		// note that this event handling is intentionally pessimistic
545 545
 		// clearing the cache to often is better than not enough
546 546
 
547
-		$this->eventDispatcher->addListener(UserAddedEvent::class, function (UserAddedEvent $event) {
547
+		$this->eventDispatcher->addListener(UserAddedEvent::class, function(UserAddedEvent $event) {
548 548
 			$this->cache->remove($event->getUser()->getUID());
549 549
 		});
550
-		$this->eventDispatcher->addListener(UserRemovedEvent::class, function (UserRemovedEvent $event) {
550
+		$this->eventDispatcher->addListener(UserRemovedEvent::class, function(UserRemovedEvent $event) {
551 551
 			$this->cache->remove($event->getUser()->getUID());
552 552
 		});
553
-		$this->eventDispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event) {
553
+		$this->eventDispatcher->addListener(ShareCreatedEvent::class, function(ShareCreatedEvent $event) {
554 554
 			$this->cache->remove($event->getShare()->getSharedWith());
555 555
 		});
556
-		$this->eventDispatcher->addListener(InvalidateMountCacheEvent::class, function (InvalidateMountCacheEvent $event
556
+		$this->eventDispatcher->addListener(InvalidateMountCacheEvent::class, function(InvalidateMountCacheEvent $event
557 557
 		) {
558 558
 			if ($user = $event->getUser()) {
559 559
 				$this->cache->remove($user->getUID());
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 		];
571 571
 
572 572
 		foreach ($genericEvents as $genericEvent) {
573
-			$this->eventDispatcher->addListener($genericEvent, function ($event) {
573
+			$this->eventDispatcher->addListener($genericEvent, function($event) {
574 574
 				$this->cache->clear();
575 575
 			});
576 576
 		}
Please login to merge, or discard this patch.