diff options
author | Christopher Ng <chrng8@gmail.com> | 2022-03-24 02:32:21 +0000 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2022-03-29 23:12:52 +0000 |
commit | e4f1d4192aec29cb8a083fb3e64cd03fcb0162b8 (patch) | |
tree | 841da9c602132c481f173a90b964f62eea8145d4 /apps/dav/lib/UserMigration | |
parent | 576e4e8f2a0aebf31d38d59cb7d9c9839e8e253b (diff) | |
download | nextcloud-server-e4f1d4192aec29cb8a083fb3e64cd03fcb0162b8.tar.gz nextcloud-server-e4f1d4192aec29cb8a083fb3e64cd03fcb0162b8.zip |
Skip import of current calendar on error
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/dav/lib/UserMigration')
-rw-r--r-- | apps/dav/lib/UserMigration/CalendarMigrator.php | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/apps/dav/lib/UserMigration/CalendarMigrator.php b/apps/dav/lib/UserMigration/CalendarMigrator.php index d0d9e94351b..8d2f493555f 100644 --- a/apps/dav/lib/UserMigration/CalendarMigrator.php +++ b/apps/dav/lib/UserMigration/CalendarMigrator.php @@ -318,6 +318,9 @@ class CalendarMigrator implements IMigrator { return $vCalendarObject; } + /** + * @throws InvalidCalendarException + */ private function importCalendarObject(int $calendarId, VCalendar $vCalendarObject, OutputInterface $output): void { try { $this->calDavBackend->createCalendarObject( @@ -330,11 +333,12 @@ class CalendarMigrator implements IMigrator { // Rollback creation of calendar on error $output->writeln('Error creating calendar object, rolling back creation of calendar…'); $this->calDavBackend->deleteCalendar($calendarId, true); + throw new InvalidCalendarException(); } } /** - * @throws CalendarMigratorException + * @throws InvalidCalendarException */ private function importCalendar(IUser $user, string $filename, string $initialCalendarUri, VCalendar $vCalendar, OutputInterface $output): void { $principalUri = $this->getPrincipalUri($user); @@ -446,15 +450,19 @@ class CalendarMigrator implements IMigrator { } [$initialCalendarUri, $suffix] = $splitFilename; - $this->importCalendar( - $user, - $filename, - $initialCalendarUri, - $vCalendar, - $output, - ); - - $vCalendar->destroy(); + try { + $this->importCalendar( + $user, + $filename, + $initialCalendarUri, + $vCalendar, + $output, + ); + } catch (InvalidCalendarException $e) { + // Allow this exception to skip a failed import + } finally { + $vCalendar->destroy(); + } } } } |