Skip to content

Commit

Permalink
Skip import of current calendar on error
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Mar 25, 2022
1 parent c407bb9 commit f035cb4
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions apps/dav/lib/UserMigration/CalendarMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ private function initCalendarObject(): VCalendar {
return $vCalendarObject;
}

/**
* @throws InvalidCalendarException
*/
private function importCalendarObject(int $calendarId, VCalendar $vCalendarObject, OutputInterface $output): void {
try {
$this->calDavBackend->createCalendarObject(
Expand All @@ -330,11 +333,12 @@ private function importCalendarObject(int $calendarId, VCalendar $vCalendarObjec
// 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);
Expand Down Expand Up @@ -446,13 +450,18 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
}
[$initialCalendarUri, $suffix] = $splitFilename;

$this->importCalendar(
$user,
$filename,
$initialCalendarUri,
$vCalendar,
$output,
);
try {
$this->importCalendar(
$user,
$filename,
$initialCalendarUri,
$vCalendar,
$output,
);
} catch (InvalidCalendarException $e) {
// Skip import of current calendar on error
continue;
}

$vCalendar->destroy();
}
Expand Down

0 comments on commit f035cb4

Please sign in to comment.