Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-04-12 17:25:13 +0300
committerVincent Petry <vincent@nextcloud.com>2022-04-13 17:52:40 +0300
commit0fd72f4355c73a2f859e074754f0f255db16f536 (patch)
tree085a8c4438446f2f73b47f70f972c979b3ce0ef4 /apps/dav/lib/UserMigration/ContactsMigrator.php
parenta77ffe85936ab1ea9184935714b65320de95679a (diff)
Adapt existing migrators to new API
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/dav/lib/UserMigration/ContactsMigrator.php')
-rw-r--r--apps/dav/lib/UserMigration/ContactsMigrator.php38
1 files changed, 19 insertions, 19 deletions
diff --git a/apps/dav/lib/UserMigration/ContactsMigrator.php b/apps/dav/lib/UserMigration/ContactsMigrator.php
index 99eea2700a5..6a292eff8e8 100644
--- a/apps/dav/lib/UserMigration/ContactsMigrator.php
+++ b/apps/dav/lib/UserMigration/ContactsMigrator.php
@@ -205,26 +205,26 @@ class ContactsMigrator implements IMigrator {
$output->writeln('No contacts to export…');
}
- /**
- * @var string $name
- * @var string $displayName
- * @var ?string $description
- * @var VCard[] $vCards
- */
- foreach ($addressBookExports as ['name' => $name, 'displayName' => $displayName, 'description' => $description, 'vCards' => $vCards]) {
- // Set filename to sanitized address book name appended with the date
- $basename = preg_replace('/[^a-zA-Z0-9-_ ]/um', '', $name) . '_' . date('Y-m-d');
- $exportPath = ContactsMigrator::PATH_ROOT . $basename . '.' . ContactsMigrator::FILENAME_EXT;
- $metadataExportPath = ContactsMigrator::PATH_ROOT . $basename . '.' . ContactsMigrator::METADATA_EXT;
-
- if ($exportDestination->addFileContents($exportPath, $this->serializeCards($vCards)) === false) {
- throw new ContactsMigratorException('Could not export address book');
- }
-
- $metadata = array_filter(['displayName' => $displayName, 'description' => $description]);
- if ($exportDestination->addFileContents($metadataExportPath, json_encode($metadata)) === false) {
- throw new ContactsMigratorException('Could not export address book metadata');
+ try {
+ /**
+ * @var string $name
+ * @var string $displayName
+ * @var ?string $description
+ * @var VCard[] $vCards
+ */
+ foreach ($addressBookExports as ['name' => $name, 'displayName' => $displayName, 'description' => $description, 'vCards' => $vCards]) {
+ // Set filename to sanitized address book name appended with the date
+ $basename = preg_replace('/[^a-zA-Z0-9-_ ]/um', '', $name) . '_' . date('Y-m-d');
+ $exportPath = ContactsMigrator::PATH_ROOT . $basename . '.' . ContactsMigrator::FILENAME_EXT;
+ $metadataExportPath = ContactsMigrator::PATH_ROOT . $basename . '.' . ContactsMigrator::METADATA_EXT;
+
+ $exportDestination->addFileContents($exportPath, $this->serializeCards($vCards);
+
+ $metadata = array_filter(['displayName' => $displayName, 'description' => $description]);
+ $exportDestination->addFileContents($metadataExportPath, json_encode($metadata);
}
+ } catch (Throwable $e) {
+ throw new CalendarMigratorException('Could not export address book', 0, $e);
}
}