summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-04-13 09:56:07 +0200
committerVincent Petry <vincent@nextcloud.com>2022-04-13 16:52:40 +0200
commit78c8e578966e3867f583ca3a2aacda583c5ecfbd (patch)
tree765ea9fa2d07f0c581a014fce5f5a658dd5ef94f /apps
parent0fd72f4355c73a2f859e074754f0f255db16f536 (diff)
downloadnextcloud-server-78c8e578966e3867f583ca3a2aacda583c5ecfbd.tar.gz
nextcloud-server-78c8e578966e3867f583ca3a2aacda583c5ecfbd.zip
Fix migrators according to exceptions
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>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/UserMigration/ContactsMigrator.php4
-rw-r--r--apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php10
-rw-r--r--apps/settings/tests/UserMigration/AccountMigratorTest.php6
3 files changed, 10 insertions, 10 deletions
diff --git a/apps/dav/lib/UserMigration/ContactsMigrator.php b/apps/dav/lib/UserMigration/ContactsMigrator.php
index 6a292eff8e8..065ef05ceea 100644
--- a/apps/dav/lib/UserMigration/ContactsMigrator.php
+++ b/apps/dav/lib/UserMigration/ContactsMigrator.php
@@ -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);
diff --git a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
index db5231ae019..dbc6267eb3a 100644
--- a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
+++ b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php
@@ -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();
diff --git a/apps/settings/tests/UserMigration/AccountMigratorTest.php b/apps/settings/tests/UserMigration/AccountMigratorTest.php
index 759e7d8a842..573d18380e5 100644
--- a/apps/settings/tests/UserMigration/AccountMigratorTest.php
+++ b/apps/settings/tests/UserMigration/AccountMigratorTest.php
@@ -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);
}