Passed
Push — master ( 436a08...8f1e71 )
by Robin
19:50 queued 14s
created
lib/private/Files/Config/UserMountCache.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 	public function registerMounts(IUser $user, array $mounts, array $mountProviderClasses = null) {
80 80
 		$this->eventLogger->start('fs:setup:user:register', 'Registering mounts for user');
81 81
 		// filter out non-proper storages coming from unit tests
82
-		$mounts = array_filter($mounts, function (IMountPoint $mount) {
82
+		$mounts = array_filter($mounts, function(IMountPoint $mount) {
83 83
 			return $mount instanceof SharedMount || ($mount->getStorage() && $mount->getStorage()->getCache());
84 84
 		});
85 85
 		/** @var ICachedMountInfo[] $newMounts */
86
-		$newMounts = array_map(function (IMountPoint $mount) use ($user) {
86
+		$newMounts = array_map(function(IMountPoint $mount) use ($user) {
87 87
 			// filter out any storages which aren't scanned yet since we aren't interested in files from those storages (yet)
88 88
 			if ($mount->getStorageRootId() === -1) {
89 89
 				return null;
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 			}
93 93
 		}, $mounts);
94 94
 		$newMounts = array_values(array_filter($newMounts));
95
-		$newMountKeys = array_map(function (ICachedMountInfo $mount) {
96
-			return $mount->getRootId() . '::' . $mount->getMountPoint();
95
+		$newMountKeys = array_map(function(ICachedMountInfo $mount) {
96
+			return $mount->getRootId().'::'.$mount->getMountPoint();
97 97
 		}, $newMounts);
98 98
 		$newMounts = array_combine($newMountKeys, $newMounts);
99 99
 
100 100
 		$cachedMounts = $this->getMountsForUser($user);
101 101
 		if (is_array($mountProviderClasses)) {
102
-			$cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) {
102
+			$cachedMounts = array_filter($cachedMounts, function(ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) {
103 103
 				// for existing mounts that didn't have a mount provider set
104 104
 				// we still want the ones that map to new mounts
105
-				$mountKey = $mountInfo->getRootId() . '::' . $mountInfo->getMountPoint();
105
+				$mountKey = $mountInfo->getRootId().'::'.$mountInfo->getMountPoint();
106 106
 				if ($mountInfo->getMountProvider() === '' && isset($newMounts[$mountKey])) {
107 107
 					return true;
108 108
 				}
109 109
 				return in_array($mountInfo->getMountProvider(), $mountProviderClasses);
110 110
 			});
111 111
 		}
112
-		$cachedRootKeys = array_map(function (ICachedMountInfo $mount) {
113
-			return $mount->getRootId() . '::' . $mount->getMountPoint();
112
+		$cachedRootKeys = array_map(function(ICachedMountInfo $mount) {
113
+			return $mount->getRootId().'::'.$mount->getMountPoint();
114 114
 		}, $cachedMounts);
115 115
 		$cachedMounts = array_combine($cachedRootKeys, $cachedMounts);
116 116
 
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 	private function findChangedMounts(array $newMounts, array $cachedMounts) {
163 163
 		$new = [];
164 164
 		foreach ($newMounts as $mount) {
165
-			$new[$mount->getRootId() . '::' . $mount->getMountPoint()] = $mount;
165
+			$new[$mount->getRootId().'::'.$mount->getMountPoint()] = $mount;
166 166
 		}
167 167
 		$changed = [];
168 168
 		foreach ($cachedMounts as $cachedMount) {
169
-			$key = $cachedMount->getRootId() . '::' . $cachedMount->getMountPoint();
169
+			$key = $cachedMount->getRootId().'::'.$cachedMount->getMountPoint();
170 170
 			if (isset($new[$key])) {
171 171
 				$newMount = $new[$key];
172 172
 				if (
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 			], ['root_id', 'user_id', 'mount_point']);
195 195
 		} else {
196 196
 			// in some cases this is legitimate, like orphaned shares
197
-			$this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint());
197
+			$this->logger->debug('Could not get storage info for mount at '.$mount->getMountPoint());
198 198
 		}
199 199
 	}
200 200
 
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
 		}
230 230
 		$mount_id = $row['mount_id'];
231 231
 		if (!is_null($mount_id)) {
232
-			$mount_id = (int)$mount_id;
232
+			$mount_id = (int) $mount_id;
233 233
 		}
234 234
 		return new CachedMountInfo(
235 235
 			$user,
236
-			(int)$row['storage_id'],
237
-			(int)$row['root_id'],
236
+			(int) $row['storage_id'],
237
+			(int) $row['root_id'],
238 238
 			$row['mount_point'],
239 239
 			$row['mount_provider_class'] ?? '',
240 240
 			$mount_id,
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 
323 323
 			if (is_array($row)) {
324 324
 				$this->cacheInfoCache[$fileId] = [
325
-					(int)$row['storage'],
326
-					(string)$row['path'],
327
-					(int)$row['mimetype']
325
+					(int) $row['storage'],
326
+					(string) $row['path'],
327
+					(int) $row['mimetype']
328 328
 				];
329 329
 			} else {
330
-				throw new NotFoundException('File with id "' . $fileId . '" not found');
330
+				throw new NotFoundException('File with id "'.$fileId.'" not found');
331 331
 			}
332 332
 		}
333 333
 		return $this->cacheInfoCache[$fileId];
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 		$rows = $result->fetchAll();
360 360
 		$result->closeCursor();
361 361
 		// filter mounts that are from the same storage but a different directory
362
-		$filteredMounts = array_filter($rows, function (array $row) use ($internalPath, $fileId) {
363
-			if ($fileId === (int)$row['root_id']) {
362
+		$filteredMounts = array_filter($rows, function(array $row) use ($internalPath, $fileId) {
363
+			if ($fileId === (int) $row['root_id']) {
364 364
 				return true;
365 365
 			}
366 366
 			$internalMountPath = $row['path'] ?? '';
367 367
 
368
-			return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/';
368
+			return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath.'/';
369 369
 		});
370 370
 
371 371
 		$filteredMounts = array_filter(array_map([$this, 'dbRowToMountInfo'], $filteredMounts));
372
-		return array_map(function (ICachedMountInfo $mount) use ($internalPath) {
372
+		return array_map(function(ICachedMountInfo $mount) use ($internalPath) {
373 373
 			return new CachedMountFileInfo(
374 374
 				$mount->getUser(),
375 375
 				$mount->getStorageId(),
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 			$slash
428 428
 		);
429 429
 
430
-		$userIds = array_map(function (IUser $user) {
430
+		$userIds = array_map(function(IUser $user) {
431 431
 			return $user->getUID();
432 432
 		}, $users);
433 433
 
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
 	public function getMountForPath(IUser $user, string $path): ICachedMountInfo {
460 460
 		$mounts = $this->getMountsForUser($user);
461
-		$mountPoints = array_map(function (ICachedMountInfo $mount) {
461
+		$mountPoints = array_map(function(ICachedMountInfo $mount) {
462 462
 			return $mount->getMountPoint();
463 463
 		}, $mounts);
464 464
 		$mounts = array_combine($mountPoints, $mounts);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 		// walk up the directory tree until we find a path that has a mountpoint set
468 468
 		// the loop will return if a mountpoint is found or break if none are found
469 469
 		while (true) {
470
-			$mountPoint = $current . '/';
470
+			$mountPoint = $current.'/';
471 471
 			if (isset($mounts[$mountPoint])) {
472 472
 				return $mounts[$mountPoint];
473 473
 			} elseif ($current === '') {
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 			}
481 481
 		}
482 482
 
483
-		throw new NotFoundException("No cached mount for path " . $path);
483
+		throw new NotFoundException("No cached mount for path ".$path);
484 484
 	}
485 485
 
486 486
 	public function getMountsInPath(IUser $user, string $path): array {
487
-		$path = rtrim($path, '/') . '/';
487
+		$path = rtrim($path, '/').'/';
488 488
 		$mounts = $this->getMountsForUser($user);
489
-		return array_filter($mounts, function (ICachedMountInfo $mount) use ($path) {
489
+		return array_filter($mounts, function(ICachedMountInfo $mount) use ($path) {
490 490
 			return $mount->getMountPoint() !== $path && strpos($mount->getMountPoint(), $path) === 0;
491 491
 		});
492 492
 	}
Please login to merge, or discard this patch.