Skip to content

Commit

Permalink
Merge pull request #741 from nextcloud/dependabot/composer/nextcloud/…
Browse files Browse the repository at this point in the history
…coding-standard-1.2.3

chore(deps-dev): Bump nextcloud/coding-standard from 1.2.1 to 1.2.3
  • Loading branch information
Pytal authored Sep 3, 2024
2 parents 35a9ae7 + 5c692ba commit 122ad00
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 62 deletions.
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Command/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

try {
if (!is_writable($folder)) {
$io->error("The target folder must exist and be writable by the web server user");
$io->error('The target folder must exist and be writable by the web server user');
return 1;
}
$folder = realpath($folder);
Expand Down
6 changes: 3 additions & 3 deletions lib/ExportDestination.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function copyFolder(Folder $folder, string $destinationPath, ?callable $n
'timestamp' => $node->getMTime(),
]);
if (!$success) {
throw new UserMigrationException("Failed to copy file into ".$destinationPath.'/'.$node->getName()." in archive");
throw new UserMigrationException('Failed to copy file into '.$destinationPath.'/'.$node->getName().' in archive');
}
} elseif ($node instanceof Folder) {
$this->copyFolder($node, $destinationPath.'/'.$node->getName(), $nodeFilter);
Expand All @@ -125,7 +125,7 @@ public function copyFolder(Folder $folder, string $destinationPath, ?callable $n
* {@inheritDoc}
*/
public function setMigratorVersions(array $versions): void {
$this->addFileContents("migrator_versions.json", json_encode($versions));
$this->addFileContents('migrator_versions.json', json_encode($versions));
}

/**
Expand All @@ -134,7 +134,7 @@ public function setMigratorVersions(array $versions): void {
public function close(): void {
$success = $this->streamer->finalize();
if (!$success) {
throw new UserMigrationException("Failed to close zip streamer");
throw new UserMigrationException('Failed to close zip streamer');
}
}

Expand Down
14 changes: 7 additions & 7 deletions lib/ImportSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function copyToFolder(Folder $destination, string $sourcePath): void {
foreach ($files as $path) {
$stat = $this->archive->getStat($sourcePath . $path);
if ($stat === null) {
throw new UserMigrationException("Failed to get stat information from archive for \"" . $sourcePath . $path . "\"");
throw new UserMigrationException('Failed to get stat information from archive for "' . $sourcePath . $path . '"');
}
if (str_ends_with($path, '/')) {
try {
Expand All @@ -116,7 +116,7 @@ public function copyToFolder(Folder $destination, string $sourcePath): void {
} else {
$stream = $this->archive->getStream($sourcePath.$path, 'r');
if ($stream === false) {
throw new UserMigrationException("Failed to get \"" . $sourcePath . $path . "\" from archive");
throw new UserMigrationException('Failed to get "' . $sourcePath . $path . '" from archive');
}
try {
$file = $destination->get($path);
Expand All @@ -133,9 +133,9 @@ public function copyToFolder(Folder $destination, string $sourcePath): void {
}
}
} catch (NotPermittedException $e) {
throw new UserMigrationException("Could not import files due to permission issue", 0, $e);
throw new UserMigrationException('Could not import files due to permission issue', 0, $e);
} catch (\Throwable $e) {
throw new UserMigrationException("Could not import files", 0, $e);
throw new UserMigrationException('Could not import files', 0, $e);
}
}

Expand All @@ -145,11 +145,11 @@ public function copyToFolder(Folder $destination, string $sourcePath): void {
public function getMigratorVersions(): array {
try {
if ($this->migratorVersions === null) {
$this->migratorVersions = json_decode($this->getFileContents("migrator_versions.json"), true, 512, JSON_THROW_ON_ERROR);
$this->migratorVersions = json_decode($this->getFileContents('migrator_versions.json'), true, 512, JSON_THROW_ON_ERROR);
}
return $this->migratorVersions;
} catch (\Exception $e) {
throw new UserMigrationException("Failed to get migrators versions", 0, $e);
throw new UserMigrationException('Failed to get migrators versions', 0, $e);
}
}

Expand All @@ -174,7 +174,7 @@ public function getOriginalUid(): string {
throw new UserMigrationException('No uid found in '.static::PATH_USER);
}
} catch (\Exception $e) {
throw new UserMigrationException("Failed to original uid", 0, $e);
throw new UserMigrationException('Failed to original uid', 0, $e);
}
}

Expand Down
46 changes: 23 additions & 23 deletions lib/Migrator/FilesMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function export(
IExportDestination $exportDestination,
OutputInterface $output
): void {
$output->writeln("Exporting files…");
$output->writeln('Exporting files…');

$uid = $user->getUID();
$userFolder = $this->root->getUserFolder($uid);
Expand All @@ -169,40 +169,40 @@ public function export(
try {
$exportDestination->copyFolder($userFolder, static::PATH_FILES, $nodeFilter);
} catch (\Throwable $e) {
throw new UserMigrationException("Could not export files.", 0, $e);
throw new UserMigrationException('Could not export files.', 0, $e);
}

try {
if (class_exists(FilesVersionsStorage::class)) {
$versionsFolder = $this->root->get('/'.$uid.'/'.FilesVersionsStorage::VERSIONS_ROOT);
$output->writeln("Exporting file versions…");
$output->writeln('Exporting file versions…');
try {
$exportDestination->copyFolder($versionsFolder, static::PATH_VERSIONS);
} catch (\Throwable $e) {
throw new UserMigrationException("Could not export files versions.", 0, $e);
throw new UserMigrationException('Could not export files versions.', 0, $e);
}
} else {
$output->writeln("Skip disabled app files_versions…");
$output->writeln('Skip disabled app files_versions…');
}
} catch (NotFoundException $e) {
$output->writeln("No file versions to export…");
$output->writeln('No file versions to export…');
}

$objectIds = $this->collectIds($userFolder, $userFolder->getPath(), $nodeFilter);
unset($objectIds[ExportDestination::EXPORT_FILENAME]);

$output->writeln("Exporting file tags…");
$output->writeln('Exporting file tags…');

$tagger = $this->tagManager->load(Application::APP_ID, [], false, $uid);
$tags = $tagger->getTagsForObjects(array_values($objectIds));
$taggedFiles = array_filter(array_map(fn ($id) => $tags[$id] ?? [], $objectIds));
try {
$exportDestination->addFileContents(static::PATH_TAGS, json_encode($taggedFiles));
} catch (\Throwable $e) {
throw new UserMigrationException("Could not export tagged files information.", 0, $e);
throw new UserMigrationException('Could not export tagged files information.', 0, $e);
}

$output->writeln("Exporting file systemtags…");
$output->writeln('Exporting file systemtags…');

$systemTags = $this->systemTagMapper->getTagIdsForObjects(array_values($objectIds), 'files');
$systemTags = array_map(
Expand All @@ -216,10 +216,10 @@ public function export(
try {
$exportDestination->addFileContents(static::PATH_SYSTEMTAGS, json_encode($systemTaggedFiles));
} catch (\Throwable $e) {
throw new UserMigrationException("Could not export systemtagged files information.", 0, $e);
throw new UserMigrationException('Could not export systemtagged files information.', 0, $e);
}

$output->writeln("Exporting file comments…");
$output->writeln('Exporting file comments…');

$comments = [];
foreach ($objectIds as $path => $objectId) {
Expand All @@ -242,7 +242,7 @@ function (IComment $comment): array {
try {
$exportDestination->addFileContents(static::PATH_COMMENTS, json_encode($comments));
} catch (\Throwable $e) {
throw new UserMigrationException("Could not export file comments.", 0, $e);
throw new UserMigrationException('Could not export file comments.', 0, $e);
}

// TODO other files metadata should be exported as well if relevant.
Expand All @@ -262,7 +262,7 @@ private function collectIds(Folder $folder, string $rootPath, ?callable $nodeFil
if ($node instanceof Folder) {
$this->collectIds($node, $rootPath, $nodeFilter, $objectIds);
} elseif (!($node instanceof File)) {
throw new UserMigrationException("Unsupported node type: ".get_class($node));
throw new UserMigrationException('Unsupported node type: '.get_class($node));
}
}

Expand All @@ -278,17 +278,17 @@ public function import(
OutputInterface $output
): void {
if ($importSource->getMigratorVersion($this->getId()) === null) {
$output->writeln("No version for migrator ".$this->getId()." (".static::class."), skipping import…");
$output->writeln('No version for migrator '.$this->getId().' ('.static::class.'), skipping import…');
return;
}
$output->writeln("Importing files…");
$output->writeln('Importing files…');

$uid = $user->getUID();

try {
$importSource->copyToFolder($this->root->getUserFolder($uid), static::PATH_FILES);
} catch (\Throwable $e) {
throw new UserMigrationException("Could not import files.", 0, $e);
throw new UserMigrationException('Could not import files.', 0, $e);
}

$userFolder = $this->root->getUserFolder($uid);
Expand All @@ -300,20 +300,20 @@ public function import(
} catch (NotFoundException $e) {
$versionsFolder = $this->root->newFolder('/'.$uid.'/'.FilesVersionsStorage::VERSIONS_ROOT);
}
$output->writeln("Importing file versions…");
$output->writeln('Importing file versions…');
try {
$importSource->copyToFolder($versionsFolder, static::PATH_VERSIONS);
} catch (\Throwable $e) {
throw new UserMigrationException("Could not import files versions.", 0, $e);
throw new UserMigrationException('Could not import files versions.', 0, $e);
}
} else {
$output->writeln("Skip disabled app files_versions…");
$output->writeln('Skip disabled app files_versions…');
}
} else {
$output->writeln("No file versions to import…");
$output->writeln('No file versions to import…');
}

$output->writeln("Importing file tags…");
$output->writeln('Importing file tags…');

$taggedFiles = json_decode($importSource->getFileContents(static::PATH_TAGS), true, 512, JSON_THROW_ON_ERROR);
$tagger = $this->tagManager->load(Application::APP_ID, [], false, $uid);
Expand All @@ -325,7 +325,7 @@ public function import(
}
}

$output->writeln("Importing file systemtags…");
$output->writeln('Importing file systemtags…');

$systemTaggedFiles = json_decode($importSource->getFileContents(static::PATH_SYSTEMTAGS), true, 512, JSON_THROW_ON_ERROR);
foreach ($systemTaggedFiles as $path => $systemTags) {
Expand All @@ -343,7 +343,7 @@ public function import(
}
}

$output->writeln("Importing file comments…");
$output->writeln('Importing file comments…');

$comments = json_decode($importSource->getFileContents(static::PATH_COMMENTS), true, 512, JSON_THROW_ON_ERROR);
foreach ($comments as $path => $fileComments) {
Expand Down
Loading

0 comments on commit 122ad00

Please sign in to comment.