Completed
Push — master ( 5bf67f...86f0cb )
by
unknown
28:56
created
apps/files/lib/Command/TransferOwnership.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -100,25 +100,25 @@  discard block
 block discarded – undo
100 100
 		$destinationUserObject = $this->userManager->get($input->getArgument('destination-user'));
101 101
 
102 102
 		if (!$sourceUserObject instanceof IUser) {
103
-			$output->writeln('<error>Unknown source user ' . $input->getArgument('source-user') . '</error>');
103
+			$output->writeln('<error>Unknown source user '.$input->getArgument('source-user').'</error>');
104 104
 			return self::FAILURE;
105 105
 		}
106 106
 
107 107
 		if (!$destinationUserObject instanceof IUser) {
108
-			$output->writeln('<error>Unknown destination user ' . $input->getArgument('destination-user') . '</error>');
108
+			$output->writeln('<error>Unknown destination user '.$input->getArgument('destination-user').'</error>');
109 109
 			return self::FAILURE;
110 110
 		}
111 111
 
112 112
 		$path = ltrim($input->getOption('path'), '/');
113 113
 		$includeExternalStorage = $input->getOption('include-external-storage');
114 114
 		if ($includeExternalStorage) {
115
-			$mounts = $this->mountManager->findIn('/' . rtrim($sourceUserObject->getUID() . '/files/' . $path, '/'));
115
+			$mounts = $this->mountManager->findIn('/'.rtrim($sourceUserObject->getUID().'/files/'.$path, '/'));
116 116
 			/** @var IMountPoint[] $mounts */
117 117
 			$mounts = array_filter($mounts, fn ($mount) => $mount->getMountProvider() === ConfigAdapter::class);
118 118
 			if (count($mounts) > 0) {
119
-				$output->writeln(count($mounts) . ' external storages will be transferred:');
119
+				$output->writeln(count($mounts).' external storages will be transferred:');
120 120
 				foreach ($mounts as $mount) {
121
-					$output->writeln('  - <info>' . $mount->getMountPoint() . '</info>');
121
+					$output->writeln('  - <info>'.$mount->getMountPoint().'</info>');
122 122
 				}
123 123
 				$output->writeln('');
124 124
 				$output->writeln('<comment>Any other users with access to these external storages will lose access to the files.</comment>');
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 				$input->getOption('use-user-id') === true,
147 147
 			);
148 148
 		} catch (TransferOwnershipException $e) {
149
-			$output->writeln('<error>' . $e->getMessage() . '</error>');
149
+			$output->writeln('<error>'.$e->getMessage().'</error>');
150 150
 			return $e->getCode() !== 0 ? $e->getCode() : self::FAILURE;
151 151
 		}
152 152
 
Please login to merge, or discard this patch.
apps/files/lib/Service/OwnershipTransferService.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		$output = $output ?? new NullOutput();
79 79
 		$sourceUid = $sourceUser->getUID();
80 80
 		$destinationUid = $destinationUser->getUID();
81
-		$sourcePath = rtrim($sourceUid . '/files/' . $path, '/');
81
+		$sourcePath = rtrim($sourceUid.'/files/'.$path, '/');
82 82
 
83 83
 		// If encryption is on we have to ensure the user has logged in before and that all encryption modules are ready
84 84
 		if (($this->encryptionManager->isEnabled() && $destinationUser->getLastLogin() === 0)
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 				}
115 115
 			}
116 116
 
117
-			$finalTarget = "$destinationUid/files/" . $this->sanitizeFolderName($l->t('Transferred from %1$s on %2$s', [$cleanUserName, $date]));
117
+			$finalTarget = "$destinationUid/files/".$this->sanitizeFolderName($l->t('Transferred from %1$s on %2$s', [$cleanUserName, $date]));
118 118
 			try {
119 119
 				$view->verifyPath(dirname($finalTarget), basename($finalTarget));
120 120
 			} catch (InvalidPathException $e) {
121
-				$finalTarget = "$destinationUid/files/" . $this->sanitizeFolderName($l->t('Transferred from %1$s on %2$s', [$sourceUid, $date]));
121
+				$finalTarget = "$destinationUid/files/".$this->sanitizeFolderName($l->t('Transferred from %1$s on %2$s', [$sourceUid, $date]));
122 122
 			}
123 123
 		}
124 124
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 			$move
189 189
 		);
190 190
 
191
-		$destinationPath = $finalTarget . '/' . $path;
191
+		$destinationPath = $finalTarget.'/'.$path;
192 192
 		// restore the shares
193 193
 		$this->restoreShares(
194 194
 			$sourceUid,
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 			throw new TransferOwnershipException("Unknown path provided: $sourcePath", 1);
240 240
 		}
241 241
 		$size = $sourceFileInfo->getSize(false);
242
-		$freeSpace = $view->free_space($destinationUid . '/files/');
242
+		$freeSpace = $view->free_space($destinationUid.'/files/');
243 243
 		if ($size > $freeSpace && $freeSpace !== FileInfo::SPACE_UNKNOWN) {
244 244
 			throw new TransferOwnershipException('Target user does not have enough free space available.', 1);
245 245
 		}
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 				$encryptedFiles[] = $sourceFileInfo;
261 261
 			} else {
262 262
 				$this->walkFiles($view, $sourcePath,
263
-					function (FileInfo $fileInfo) use ($progress, $masterKeyEnabled, &$encryptedFiles, $includeExternalStorage) {
263
+					function(FileInfo $fileInfo) use ($progress, $masterKeyEnabled, &$encryptedFiles, $includeExternalStorage) {
264 264
 						if ($fileInfo->getType() === FileInfo::TYPE_FOLDER) {
265 265
 							$mount = $fileInfo->getMountPoint();
266 266
 							// only analyze into folders from main storage,
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 			$output->writeln('<error>Some files are encrypted - please decrypt them first.</error>');
298 298
 			foreach ($encryptedFiles as $encryptedFile) {
299 299
 				/** @var FileInfo $encryptedFile */
300
-				$output->writeln('  ' . $encryptedFile->getPath());
300
+				$output->writeln('  '.$encryptedFile->getPath());
301 301
 			}
302 302
 			throw new TransferOwnershipException('Some files are encrypted - please decrypt them first.', 1);
303 303
 		}
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
 					break;
341 341
 				}
342 342
 				if ($path !== "$sourceUid/files") {
343
-					$sharePage = array_filter($sharePage, function (IShare $share) use ($view, $normalizedPath) {
343
+					$sharePage = array_filter($sharePage, function(IShare $share) use ($view, $normalizedPath) {
344 344
 						try {
345 345
 							$sourceNode = $share->getNode();
346 346
 							$relativePath = $view->getRelativePath($sourceNode->getPath());
347 347
 
348
-							return str_starts_with($relativePath . '/', $normalizedPath . '/');
348
+							return str_starts_with($relativePath.'/', $normalizedPath.'/');
349 349
 						} catch (Exception $e) {
350 350
 							return false;
351 351
 						}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		$progress->finish();
360 360
 		$output->writeln('');
361 361
 
362
-		return array_values(array_filter(array_map(function (IShare $share) use ($view, $normalizedPath, $output, $sourceUid) {
362
+		return array_values(array_filter(array_map(function(IShare $share) use ($view, $normalizedPath, $output, $sourceUid) {
363 363
 			try {
364 364
 				$nodePath = $view->getRelativePath($share->getNode()->getPath());
365 365
 			} catch (NotFoundException $e) {
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 			}
395 395
 
396 396
 			if ($path !== null && $path !== "$sourceUid/files") {
397
-				$sharePage = array_filter($sharePage, static function (IShare $share) use ($sourceUid, $normalizedPath) {
397
+				$sharePage = array_filter($sharePage, static function(IShare $share) use ($sourceUid, $normalizedPath) {
398 398
 					try {
399
-						return str_starts_with(Filesystem::normalizePath($sourceUid . '/files' . $share->getTarget() . '/', false), $normalizedPath . '/');
399
+						return str_starts_with(Filesystem::normalizePath($sourceUid.'/files'.$share->getTarget().'/', false), $normalizedPath.'/');
400 400
 					} catch (Exception) {
401 401
 						return false;
402 402
 					}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 		// Else only the content inside folder is transferred which is not correct.
434 434
 		if ($sourcePath !== "$sourceUid/files") {
435 435
 			$view->mkdir($finalTarget);
436
-			$finalTarget = $finalTarget . '/' . basename($sourcePath);
436
+			$finalTarget = $finalTarget.'/'.basename($sourcePath);
437 437
 		}
438 438
 		$sourceInfo = $view->getFileInfo($sourcePath);
439 439
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 			foreach ($nestedMounts as $mount) {
452 452
 				if ($mount->getMountProvider() === ConfigAdapter::class) {
453 453
 					$relativePath = substr(trim($mount->getMountPoint(), '/'), strlen($sourcePath));
454
-					$this->moveMountContents($view, $mount->getMountPoint(), $finalTarget . $relativePath);
454
+					$this->moveMountContents($view, $mount->getMountPoint(), $finalTarget.$relativePath);
455 455
 				}
456 456
 			}
457 457
 		}
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 
496 496
 		foreach ($shares as ['share' => $share, 'suffix' => $suffix]) {
497 497
 			try {
498
-				$output->writeln('Transfering share ' . $share->getId() . ' of type ' . $share->getShareType(), OutputInterface::VERBOSITY_VERBOSE);
498
+				$output->writeln('Transfering share '.$share->getId().' of type '.$share->getShareType(), OutputInterface::VERBOSITY_VERBOSE);
499 499
 				if ($share->getShareType() === IShare::TYPE_USER
500 500
 					&& $share->getSharedWith() === $destinationUid) {
501 501
 					// Unmount the shares before deleting, so we don't try to get the storage later on.
502
-					$shareMountPoint = $this->mountManager->find('/' . $destinationUid . '/files' . $share->getTarget());
502
+					$shareMountPoint = $this->mountManager->find('/'.$destinationUid.'/files'.$share->getTarget());
503 503
 					if ($shareMountPoint) {
504 504
 						$this->mountManager->removeMount($shareMountPoint->getMountPoint());
505 505
 					}
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 					if ($share->getShareType() === IShare::TYPE_USER
516 516
 						&& !$this->userManager->userExists($share->getSharedWith())) {
517 517
 						// stray share with deleted user
518
-						$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted user "' . $share->getSharedWith() . '", deleting</error>');
518
+						$output->writeln('<error>Share with id '.$share->getId().' points at deleted user "'.$share->getSharedWith().'", deleting</error>');
519 519
 						$this->shareManager->deleteShare($share);
520 520
 						continue;
521 521
 					} else {
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
 						} catch (NotFoundException) {
532 532
 							// ID has changed due to transfer between different storages
533 533
 							// Try to get the new ID from the target path and suffix of the share
534
-							$node = $this->rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
534
+							$node = $this->rootFolder->get(Filesystem::normalizePath($targetLocation.'/'.$suffix));
535 535
 							$newNodeId = $node->getId();
536
-							$output->writeln('Had to change node id to ' . $newNodeId, OutputInterface::VERBOSITY_VERY_VERBOSE);
536
+							$output->writeln('Had to change node id to '.$newNodeId, OutputInterface::VERBOSITY_VERY_VERBOSE);
537 537
 						}
538 538
 						$share->setNodeId($newNodeId);
539 539
 
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
 					}
542 542
 				}
543 543
 			} catch (NotFoundException $e) {
544
-				$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
544
+				$output->writeln('<error>Share with id '.$share->getId().' points at deleted file, skipping</error>');
545 545
 			} catch (\Throwable $e) {
546
-				$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getMessage() . ' : ' . $e->getTraceAsString() . '</error>');
546
+				$output->writeln('<error>Could not restore share with id '.$share->getId().':'.$e->getMessage().' : '.$e->getTraceAsString().'</error>');
547 547
 			}
548 548
 			$progress->advance();
549 549
 		}
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 				// Only restore if share is in given path.
572 572
 				$pathToCheck = '/';
573 573
 				if (trim($path, '/') !== '') {
574
-					$pathToCheck = '/' . trim($path) . '/';
574
+					$pathToCheck = '/'.trim($path).'/';
575 575
 				}
576 576
 				if (!str_starts_with($share->getTarget(), $pathToCheck)) {
577 577
 					continue;
578 578
 				}
579 579
 				$shareTarget = $share->getTarget();
580
-				$shareTarget = $finalShareTarget . $shareTarget;
580
+				$shareTarget = $finalShareTarget.$shareTarget;
581 581
 				if ($share->getShareType() === IShare::TYPE_USER
582 582
 					&& $share->getSharedBy() === $destinationUid) {
583 583
 					$this->shareManager->deleteShare($share);
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 					continue;
622 622
 				}
623 623
 			} catch (NotFoundException $e) {
624
-				$output->writeln('<error>Share with id ' . $share->getId() . ' points at deleted file, skipping</error>');
624
+				$output->writeln('<error>Share with id '.$share->getId().' points at deleted file, skipping</error>');
625 625
 			} catch (\Throwable $e) {
626
-				$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getTraceAsString() . '</error>');
626
+				$output->writeln('<error>Could not restore share with id '.$share->getId().':'.$e->getTraceAsString().'</error>');
627 627
 			}
628 628
 			$progress->advance();
629 629
 		}
Please login to merge, or discard this patch.