Passed
Push — master ( fda9d4...36835b )
by Robin
15:18 queued 12s
created
lib/private/Files/SetupManager.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 		OC_App::loadApps(['filesystem']);
133 133
 		$prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false);
134 134
 
135
-		Filesystem::addStorageWrapper('mount_options', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
135
+		Filesystem::addStorageWrapper('mount_options', function($mountPoint, IStorage $storage, IMountPoint $mount) {
136 136
 			if ($storage->instanceOfStorage(Common::class)) {
137 137
 				$storage->setMountOptions($mount->getOptions());
138 138
 			}
139 139
 			return $storage;
140 140
 		});
141 141
 
142
-		Filesystem::addStorageWrapper('enable_sharing', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
142
+		Filesystem::addStorageWrapper('enable_sharing', function($mountPoint, IStorage $storage, IMountPoint $mount) {
143 143
 			if (!$mount->getOption('enable_sharing', true)) {
144 144
 				return new PermissionsMask([
145 145
 					'storage' => $storage,
@@ -150,21 +150,21 @@  discard block
 block discarded – undo
150 150
 		});
151 151
 
152 152
 		// install storage availability wrapper, before most other wrappers
153
-		Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, IStorage $storage) {
153
+		Filesystem::addStorageWrapper('oc_availability', function($mountPoint, IStorage $storage) {
154 154
 			if (!$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) {
155 155
 				return new Availability(['storage' => $storage]);
156 156
 			}
157 157
 			return $storage;
158 158
 		});
159 159
 
160
-		Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
160
+		Filesystem::addStorageWrapper('oc_encoding', function($mountPoint, IStorage $storage, IMountPoint $mount) {
161 161
 			if ($mount->getOption('encoding_compatibility', false) && !$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
162 162
 				return new Encoding(['storage' => $storage]);
163 163
 			}
164 164
 			return $storage;
165 165
 		});
166 166
 
167
-		Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) {
167
+		Filesystem::addStorageWrapper('oc_quota', function($mountPoint, $storage) {
168 168
 			// set up quota for home storages, even for other users
169 169
 			// which can happen when using sharing
170 170
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 			if ($storage->instanceOfStorage(HomeObjectStoreStorage::class) || $storage->instanceOfStorage(Home::class)) {
175 175
 				if (is_object($storage->getUser())) {
176 176
 					$user = $storage->getUser();
177
-					return new Quota(['storage' => $storage, 'quotaCallback' => function () use ($user) {
177
+					return new Quota(['storage' => $storage, 'quotaCallback' => function() use ($user) {
178 178
 						return OC_Util::getUserQuota($user);
179 179
 					}, 'root' => 'files']);
180 180
 				}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			return $storage;
184 184
 		});
185 185
 
186
-		Filesystem::addStorageWrapper('readonly', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
186
+		Filesystem::addStorageWrapper('readonly', function($mountPoint, IStorage $storage, IMountPoint $mount) {
187 187
 			/*
188 188
 			 * Do not allow any operations that modify the storage
189 189
 			 */
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 
221 221
 		$previouslySetupProviders = $this->setupUserMountProviders[$user->getUID()];
222 222
 
223
-		$this->setupForUserWith($user, function () use ($user) {
224
-			$this->mountProviderCollection->addMountForUser($user, $this->mountManager, function (
223
+		$this->setupForUserWith($user, function() use ($user) {
224
+			$this->mountProviderCollection->addMountForUser($user, $this->mountManager, function(
225 225
 				IMountProvider $provider
226 226
 			) use ($user) {
227 227
 				return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 		Filesystem::logWarningWhenAddingStorageWrapper($prevLogging);
254 254
 
255
-		$userDir = '/' . $user->getUID() . '/files';
255
+		$userDir = '/'.$user->getUID().'/files';
256 256
 
257 257
 		Filesystem::initInternal($userDir);
258 258
 
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		} else {
273 273
 			$this->mountManager->addMount(new MountPoint(
274 274
 				new NullStorage([]),
275
-				'/' . $user->getUID()
275
+				'/'.$user->getUID()
276 276
 			));
277 277
 			$this->mountManager->addMount(new MountPoint(
278 278
 				new NullStorage([]),
279
-				'/' . $user->getUID() . '/files'
279
+				'/'.$user->getUID().'/files'
280 280
 			));
281 281
 			$this->setupUsersComplete[] = $user->getUID();
282 282
 		}
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	private function afterUserFullySetup(IUser $user, array $previouslySetupProviders): void {
293 293
 		$this->eventLogger->start('fs:setup:user:full:post', 'Housekeeping after user is setup');
294
-		$userRoot = '/' . $user->getUID() . '/';
294
+		$userRoot = '/'.$user->getUID().'/';
295 295
 		$mounts = $this->mountManager->getAll();
296
-		$mounts = array_filter($mounts, function (IMountPoint $mount) use ($userRoot) {
296
+		$mounts = array_filter($mounts, function(IMountPoint $mount) use ($userRoot) {
297 297
 			return strpos($mount->getMountPoint(), $userRoot) === 0;
298 298
 		});
299
-		$allProviders = array_map(function (IMountProvider $provider) {
299
+		$allProviders = array_map(function(IMountProvider $provider) {
300 300
 			return get_class($provider);
301 301
 		}, $this->mountProviderCollection->getProviders());
302 302
 		$newProviders = array_diff($allProviders, $previouslySetupProviders);
303
-		$mounts = array_filter($mounts, function (IMountPoint $mount) use ($previouslySetupProviders) {
303
+		$mounts = array_filter($mounts, function(IMountPoint $mount) use ($previouslySetupProviders) {
304 304
 			return !in_array($mount->getMountProvider(), $previouslySetupProviders);
305 305
 		});
306 306
 		$this->userMountCache->registerMounts($user, $mounts, $newProviders);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		\OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', ['user' => $user->getUID()]);
331 331
 		$this->eventLogger->end('fs:setup:user:post-init-mountpoint');
332 332
 
333
-		$userDir = '/' . $user->getUID() . '/files';
333
+		$userDir = '/'.$user->getUID().'/files';
334 334
 		$this->eventLogger->start('fs:setup:user:setup-hook', 'setup legacy hook');
335 335
 		OC_Hook::emit('OC_Filesystem', 'setup', ['user' => $user->getUID(), 'user_dir' => $userDir]);
336 336
 		$this->eventLogger->end('fs:setup:user:setup-hook');
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			} else {
374 374
 				return null;
375 375
 			}
376
-		} elseif (strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
376
+		} elseif (strpos($path, '/appdata_'.\OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
377 377
 			return null;
378 378
 		} else {
379 379
 			[, $userId] = explode('/', $path);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		}
403 403
 
404 404
 		// for the user's home folder, and includes children we need everything always
405
-		if (rtrim($path) === "/" . $user->getUID() . "/files" && $includeChildren) {
405
+		if (rtrim($path) === "/".$user->getUID()."/files" && $includeChildren) {
406 406
 			$this->setupForUser($user);
407 407
 			return;
408 408
 		}
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 				$setupProviders[] = $cachedMount->getMountProvider();
433 433
 				$mounts = $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]);
434 434
 			} else {
435
-				$this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
435
+				$this->logger->debug("mount at ".$cachedMount->getMountPoint()." has no provider set, performing full setup");
436 436
 				$this->eventLogger->end('fs:setup:user:path:find');
437 437
 				$this->setupForUser($user);
438 438
 				$this->eventLogger->end('fs:setup:user:path');
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 			$subCachedMounts = $this->userMountCache->getMountsInPath($user, $path);
445 445
 			$this->eventLogger->end('fs:setup:user:path:find');
446 446
 
447
-			$needsFullSetup = array_reduce($subCachedMounts, function (bool $needsFullSetup, ICachedMountInfo $cachedMountInfo) {
447
+			$needsFullSetup = array_reduce($subCachedMounts, function(bool $needsFullSetup, ICachedMountInfo $cachedMountInfo) {
448 448
 				return $needsFullSetup || $cachedMountInfo->getMountProvider() === '';
449 449
 			}, false);
450 450
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 
469 469
 		if (count($mounts)) {
470 470
 			$this->userMountCache->registerMounts($user, $mounts, $currentProviders);
471
-			$this->setupForUserWith($user, function () use ($mounts) {
471
+			$this->setupForUserWith($user, function() use ($mounts) {
472 472
 				array_walk($mounts, [$this->mountManager, 'addMount']);
473 473
 			});
474 474
 		} elseif (!$this->isSetupStarted($user)) {
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 			return;
508 508
 		}
509 509
 
510
-		$this->eventLogger->start('fs:setup:user:providers', "Setup filesystem for " . implode(', ', $providers));
510
+		$this->eventLogger->start('fs:setup:user:providers', "Setup filesystem for ".implode(', ', $providers));
511 511
 
512 512
 		$this->oneTimeUserSetup($user);
513 513
 
514 514
 		// home providers are always used
515
-		$providers = array_filter($providers, function (string $provider) {
515
+		$providers = array_filter($providers, function(string $provider) {
516 516
 			return !is_subclass_of($provider, IHomeMountProvider::class);
517 517
 		});
518 518
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 		}
536 536
 
537 537
 		$this->userMountCache->registerMounts($user, $mounts, $providers);
538
-		$this->setupForUserWith($user, function () use ($mounts) {
538
+		$this->setupForUserWith($user, function() use ($mounts) {
539 539
 			array_walk($mounts, [$this->mountManager, 'addMount']);
540 540
 		});
541 541
 		$this->eventLogger->end('fs:setup:user:providers');
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	private function listenForNewMountProviders() {
558 558
 		if (!$this->listeningForProviders) {
559 559
 			$this->listeningForProviders = true;
560
-			$this->mountProviderCollection->listen('\OC\Files\Config', 'registerMountProvider', function (
560
+			$this->mountProviderCollection->listen('\OC\Files\Config', 'registerMountProvider', function(
561 561
 				IMountProvider $provider
562 562
 			) {
563 563
 				foreach ($this->setupUsers as $userId) {
@@ -575,16 +575,16 @@  discard block
 block discarded – undo
575 575
 		// note that this event handling is intentionally pessimistic
576 576
 		// clearing the cache to often is better than not enough
577 577
 
578
-		$this->eventDispatcher->addListener(UserAddedEvent::class, function (UserAddedEvent $event) {
578
+		$this->eventDispatcher->addListener(UserAddedEvent::class, function(UserAddedEvent $event) {
579 579
 			$this->cache->remove($event->getUser()->getUID());
580 580
 		});
581
-		$this->eventDispatcher->addListener(UserRemovedEvent::class, function (UserRemovedEvent $event) {
581
+		$this->eventDispatcher->addListener(UserRemovedEvent::class, function(UserRemovedEvent $event) {
582 582
 			$this->cache->remove($event->getUser()->getUID());
583 583
 		});
584
-		$this->eventDispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event) {
584
+		$this->eventDispatcher->addListener(ShareCreatedEvent::class, function(ShareCreatedEvent $event) {
585 585
 			$this->cache->remove($event->getShare()->getSharedWith());
586 586
 		});
587
-		$this->eventDispatcher->addListener(InvalidateMountCacheEvent::class, function (InvalidateMountCacheEvent $event
587
+		$this->eventDispatcher->addListener(InvalidateMountCacheEvent::class, function(InvalidateMountCacheEvent $event
588 588
 		) {
589 589
 			if ($user = $event->getUser()) {
590 590
 				$this->cache->remove($user->getUID());
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		];
602 602
 
603 603
 		foreach ($genericEvents as $genericEvent) {
604
-			$this->eventDispatcher->addListener($genericEvent, function ($event) {
604
+			$this->eventDispatcher->addListener($genericEvent, function($event) {
605 605
 				$this->cache->clear();
606 606
 			});
607 607
 		}
Please login to merge, or discard this patch.