diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2024-08-23 15:10:27 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2024-08-25 19:34:58 +0200 |
commit | af6de04e9e141466dc229e444ff3f146f4a34765 (patch) | |
tree | 7b93f521865cdecdadb33637dea33bea242e7969 /apps/encryption/lib/Command | |
parent | 1cc6b3577fdbeadece7e4e6478e7f7755555b41a (diff) | |
download | nextcloud-server-af6de04e9e141466dc229e444ff3f146f4a34765.tar.gz nextcloud-server-af6de04e9e141466dc229e444ff3f146f4a34765.zip |
style: update codestyle for coding-standard 1.2.3
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'apps/encryption/lib/Command')
-rw-r--r-- | apps/encryption/lib/Command/FixEncryptedVersion.php | 16 | ||||
-rw-r--r-- | apps/encryption/lib/Command/FixKeyLocation.php | 46 |
2 files changed, 31 insertions, 31 deletions
diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php index d2764036b39..6635bb6cba9 100644 --- a/apps/encryption/lib/Command/FixEncryptedVersion.php +++ b/apps/encryption/lib/Command/FixEncryptedVersion.php @@ -80,13 +80,13 @@ class FixEncryptedVersion extends Command { $pathOption = \trim(($input->getOption('path') ?? ''), '/'); if (!$user && !$all) { - $output->writeln("Either a user id or --all needs to be provided"); + $output->writeln('Either a user id or --all needs to be provided'); return self::FAILURE; } if ($user) { if ($all) { - $output->writeln("Specifying a user id and --all are mutually exclusive"); + $output->writeln('Specifying a user id and --all are mutually exclusive'); return self::FAILURE; } @@ -100,7 +100,7 @@ class FixEncryptedVersion extends Command { $result = 0; $this->userManager->callForSeenUsers(function (IUser $user) use ($pathOption, $output, &$result) { - $output->writeln("Processing files for " . $user->getUID()); + $output->writeln('Processing files for ' . $user->getUID()); $result = $this->runForUser($user->getUID(), $pathOption, $output); return $result === 0; }); @@ -109,7 +109,7 @@ class FixEncryptedVersion extends Command { private function runForUser(string $user, string $pathOption, OutputInterface $output): int { $pathToWalk = "/$user/files"; - if ($pathOption !== "") { + if ($pathOption !== '') { $pathToWalk = "$pathToWalk/$pathOption"; } return $this->walkPathOfUser($user, $pathToWalk, $output); @@ -205,7 +205,7 @@ class FixEncryptedVersion extends Command { } return false; } catch (HintException $e) { - $this->logger->warning("Issue: " . $e->getMessage()); + $this->logger->warning('Issue: ' . $e->getMessage()); // If allowOnce is set to false, this becomes recursive. if ($ignoreCorrectEncVersionCall === true) { // Lets rectify the file by correcting encrypted version @@ -254,7 +254,7 @@ class FixEncryptedVersion extends Command { // try with zero first $cacheInfo = ['encryptedVersion' => 0, 'encrypted' => 0]; $cache->put($fileCache->getPath(), $cacheInfo); - $output->writeln("<info>Set the encrypted version to 0 (unencrypted)</info>"); + $output->writeln('<info>Set the encrypted version to 0 (unencrypted)</info>'); if ($this->verifyFileContent($path, $output, false) === true) { $output->writeln("<info>Fixed the file: \"$path\" with version 0 (unencrypted)</info>"); return true; @@ -268,7 +268,7 @@ class FixEncryptedVersion extends Command { $cache->put($fileCache->getPath(), $cacheInfo); $output->writeln("<info>Decrement the encrypted version to $encryptedVersion</info>"); if ($this->verifyFileContent($path, $output, false) === true) { - $output->writeln("<info>Fixed the file: \"$path\" with version " . $encryptedVersion . "</info>"); + $output->writeln("<info>Fixed the file: \"$path\" with version " . $encryptedVersion . '</info>'); return true; } $encryptedVersion--; @@ -291,7 +291,7 @@ class FixEncryptedVersion extends Command { $cache->put($fileCache->getPath(), $cacheInfo); $output->writeln("<info>Increment the encrypted version to $newEncryptedVersion</info>"); if ($this->verifyFileContent($path, $output, false) === true) { - $output->writeln("<info>Fixed the file: \"$path\" with version " . $newEncryptedVersion . "</info>"); + $output->writeln("<info>Fixed the file: \"$path\" with version " . $newEncryptedVersion . '</info>'); return true; } $increment++; diff --git a/apps/encryption/lib/Command/FixKeyLocation.php b/apps/encryption/lib/Command/FixKeyLocation.php index a8d30471e8f..da529a4be2f 100644 --- a/apps/encryption/lib/Command/FixKeyLocation.php +++ b/apps/encryption/lib/Command/FixKeyLocation.php @@ -42,7 +42,7 @@ class FixKeyLocation extends Command { $this->keyRootDirectory = rtrim($this->encryptionUtil->getKeyStorageRoot(), '/'); $this->rootView = new View(); if (!$encryptionManager instanceof Manager) { - throw new \Exception("Wrong encryption manager"); + throw new \Exception('Wrong encryption manager'); } $this->encryptionManager = $encryptionManager; @@ -57,7 +57,7 @@ class FixKeyLocation extends Command { ->setName('encryption:fix-key-location') ->setDescription('Fix the location of encryption keys for external storage') ->addOption('dry-run', null, InputOption::VALUE_NONE, "Only list files that require key migration, don't try to perform any migration") - ->addArgument('user', InputArgument::REQUIRED, "User id to fix the key locations for"); + ->addArgument('user', InputArgument::REQUIRED, 'User id to fix the key locations for'); } protected function execute(InputInterface $input, OutputInterface $output): int { @@ -75,7 +75,7 @@ class FixKeyLocation extends Command { foreach ($mounts as $mount) { $mountRootFolder = $this->rootFolder->get($mount->getMountPoint()); if (!$mountRootFolder instanceof Folder) { - $output->writeln("<error>System wide mount point is not a directory, skipping: " . $mount->getMountPoint() . "</error>"); + $output->writeln('<error>System wide mount point is not a directory, skipping: ' . $mount->getMountPoint() . '</error>'); continue; } @@ -89,14 +89,14 @@ class FixKeyLocation extends Command { // key was stored incorrectly as user key, migrate if ($dryRun) { - $output->writeln("<info>" . $file->getPath() . "</info> needs migration"); + $output->writeln('<info>' . $file->getPath() . '</info> needs migration'); } else { - $output->write("Migrating key for <info>" . $file->getPath() . "</info> "); + $output->write('Migrating key for <info>' . $file->getPath() . '</info> '); if ($this->copyUserKeyToSystemAndValidate($user, $file)) { - $output->writeln("<info>✓</info>"); + $output->writeln('<info>✓</info>'); } else { - $output->writeln("<fg=red>❌</>"); - $output->writeln(" Failed to validate key for <error>" . $file->getPath() . "</error>, key will not be migrated"); + $output->writeln('<fg=red>❌</>'); + $output->writeln(' Failed to validate key for <error>' . $file->getPath() . '</error>, key will not be migrated'); } } } else { @@ -107,42 +107,42 @@ class FixKeyLocation extends Command { if ($isActuallyEncrypted) { if ($dryRun) { if ($shouldBeEncrypted) { - $output->write("<info>" . $file->getPath() . "</info> needs migration"); + $output->write('<info>' . $file->getPath() . '</info> needs migration'); } else { - $output->write("<info>" . $file->getPath() . "</info> needs decryption"); + $output->write('<info>' . $file->getPath() . '</info> needs decryption'); } $foundKey = $this->findUserKeyForSystemFile($user, $file); if ($foundKey) { - $output->writeln(", valid key found at <info>" . $foundKey . "</info>"); + $output->writeln(', valid key found at <info>' . $foundKey . '</info>'); } else { - $output->writeln(" <error>❌ No key found</error>"); + $output->writeln(' <error>❌ No key found</error>'); } } else { if ($shouldBeEncrypted) { - $output->write("<info>Migrating key for " . $file->getPath() . "</info>"); + $output->write('<info>Migrating key for ' . $file->getPath() . '</info>'); } else { - $output->write("<info>Decrypting " . $file->getPath() . "</info>"); + $output->write('<info>Decrypting ' . $file->getPath() . '</info>'); } $foundKey = $this->findUserKeyForSystemFile($user, $file); if ($foundKey) { if ($shouldBeEncrypted) { $systemKeyPath = $this->getSystemKeyPath($file); $this->rootView->copy($foundKey, $systemKeyPath); - $output->writeln(" Migrated key from <info>" . $foundKey . "</info>"); + $output->writeln(' Migrated key from <info>' . $foundKey . '</info>'); } else { $this->decryptWithSystemKey($file, $foundKey); - $output->writeln(" Decrypted with key from <info>" . $foundKey . "</info>"); + $output->writeln(' Decrypted with key from <info>' . $foundKey . '</info>'); } } else { - $output->writeln(" <error>❌ No key found</error>"); + $output->writeln(' <error>❌ No key found</error>'); } } } else { if ($dryRun) { - $output->writeln("<info>" . $file->getPath() . " needs to be marked as not encrypted</info>"); + $output->writeln('<info>' . $file->getPath() . ' needs to be marked as not encrypted</info>'); } else { $this->markAsUnEncrypted($file); - $output->writeln("<info>" . $file->getPath() . " marked as not encrypted</info>"); + $output->writeln('<info>' . $file->getPath() . ' marked as not encrypted</info>'); } } } @@ -273,7 +273,7 @@ class FixKeyLocation extends Command { } /** @var resource|false $handle */ if ($handle === false) { - throw new \Exception("Failed to open " . $node->getPath()); + throw new \Exception('Failed to open ' . $node->getPath()); } return $handle; } @@ -316,7 +316,7 @@ class FixKeyLocation extends Command { /** @var false|resource $dh */ $dh = $this->rootView->opendir($basePath); if (!$dh) { - throw new \Exception("Invalid base path " . $basePath); + throw new \Exception('Invalid base path ' . $basePath); } while ($child = readdir($dh)) { if ($child != '..' && $child != '.') { @@ -366,7 +366,7 @@ class FixKeyLocation extends Command { /** @var false|resource $source */ $source = $storage->fopen($node->getInternalPath(), 'r'); if (!$source) { - throw new \Exception("Failed to open " . $node->getPath() . " with " . $key); + throw new \Exception('Failed to open ' . $node->getPath() . ' with ' . $key); } $decryptedNode = $node->getParent()->newFile($name); @@ -386,7 +386,7 @@ class FixKeyLocation extends Command { } if ($this->isDataEncrypted($decryptedNode)) { - throw new \Exception($node->getPath() . " still encrypted after attempting to decrypt with " . $key); + throw new \Exception($node->getPath() . ' still encrypted after attempting to decrypt with ' . $key); } $this->markAsUnEncrypted($decryptedNode); |