mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
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>
This commit is contained in:
parent
0fd72f4355
commit
78c8e57896
4 changed files with 11 additions and 11 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue