]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix migrators according to exceptions 31945/head
authorVincent Petry <vincent@nextcloud.com>
Wed, 13 Apr 2022 07:56:07 +0000 (09:56 +0200)
committerVincent Petry <vincent@nextcloud.com>
Wed, 13 Apr 2022 14:52:40 +0000 (16:52 +0200)
Fixed syntax errors.
Removed if condition for copyToFolder since it's void now.
Change signature of setMigratorVersions to also be void.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
apps/dav/lib/UserMigration/ContactsMigrator.php
apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
apps/settings/tests/UserMigration/AccountMigratorTest.php
lib/public/UserMigration/IExportDestination.php

index 6a292eff8e84f85a41f295238e1dd8797a77cd65..065ef05ceeafb5025345ba3bcdcab18f8ed5ecfc 100644 (file)
@@ -218,10 +218,10 @@ class ContactsMigrator implements IMigrator {
                                $exportPath = ContactsMigrator::PATH_ROOT . $basename . '.' . ContactsMigrator::FILENAME_EXT;
                                $metadataExportPath = ContactsMigrator::PATH_ROOT . $basename . '.' . ContactsMigrator::METADATA_EXT;
 
-                               $exportDestination->addFileContents($exportPath, $this->serializeCards($vCards);
+                               $exportDestination->addFileContents($exportPath, $this->serializeCards($vCards));
 
                                $metadata = array_filter(['displayName' => $displayName, 'description' => $description]);
-                               $exportDestination->addFileContents($metadataExportPath, json_encode($metadata);
+                               $exportDestination->addFileContents($metadataExportPath, json_encode($metadata));
                        }
                } catch (Throwable $e) {
                        throw new CalendarMigratorException('Could not export address book', 0, $e);
index db5231ae01981046e9919c2a31ae2432ca69d63d..dbc6267eb3aae44676367b7af515931d16e11b31 100644 (file)
@@ -79,10 +79,10 @@ class TrashbinMigrator implements IMigrator {
                        $output->writeln("Exporting trashbin files…");
                        $exportDestination->copyFolder($trashbinFolder, static::PATH_FILES_FOLDER);
                        $originalLocations = \OCA\Files_Trashbin\Trashbin::getLocations($uid);
-                       $exportDestination->addFileContents(static::PATH_LOCATIONS_FILE, json_encode($originalLocations);
+                       $exportDestination->addFileContents(static::PATH_LOCATIONS_FILE, json_encode($originalLocations));
                } catch (NotFoundException $e) {
                        $output->writeln("No trashbin to export…");
-               } catch (UserMigrationException $e) {
+               } catch (\Throwable $e) {
                        throw new UserMigrationException("Could not export trashbin: ".$e->getMessage(), 0, $e);
                }
        }
@@ -110,8 +110,10 @@ class TrashbinMigrator implements IMigrator {
                                $trashbinFolder = $this->root->newFolder('/'.$uid.'/files_trashbin');
                        }
                        $output->writeln("Importing trashbin files…");
-                       if ($importSource->copyToFolder($trashbinFolder, static::PATH_FILES_FOLDER) === false) {
-                               throw new UserMigrationException("Could not import trashbin.");
+                       try {
+                               $importSource->copyToFolder($trashbinFolder, static::PATH_FILES_FOLDER);
+                       } catch (\Throwable $e) {
+                               throw new UserMigrationException("Could not import trashbin.", 0, $e);
                        }
                        $locations = json_decode($importSource->getFileContents(static::PATH_LOCATIONS_FILE), true, 512, JSON_THROW_ON_ERROR);
                        $qb = $this->dbc->getQueryBuilder();
index 759e7d8a842e43268db37360eb79747b59109618..573d18380e52f18d7c0f3f2dc9ddf89badbe4e31 100644 (file)
@@ -152,14 +152,12 @@ class AccountMigratorTest extends TestCase {
                $this->exportDestination
                        ->expects($this->once())
                        ->method('addFileContents')
-                       ->with($this->matchesRegularExpression(self::REGEX_ACCOUNT_FILE), json_encode($exportData))
-                       ->willReturn(true);
+                       ->with($this->matchesRegularExpression(self::REGEX_ACCOUNT_FILE), json_encode($exportData));
 
                $this->exportDestination
                        ->expects($this->once())
                        ->method('addFileAsStream')
-                       ->with($this->matchesRegularExpression(self::REGEX_AVATAR_FILE), $this->isType('resource'))
-                       ->willReturn(true);
+                       ->with($this->matchesRegularExpression(self::REGEX_AVATAR_FILE), $this->isType('resource'));
 
                $this->migrator->export($user, $this->exportDestination, $this->output);
        }
index 2c5598482550b0e7f9c8d3a779ca83c2e7e3e429..65d228faeb9316a9b54b83dca2624dba5f338f78 100644 (file)
@@ -72,7 +72,7 @@ interface IExportDestination {
         *
         * @since 24.0.0
         */
-       public function setMigratorVersions(array $versions): bool;
+       public function setMigratorVersions(array $versions): void;
 
        /**
         * Called after export is complete