mirror of
https://github.com/nextcloud/server.git
synced 2026-04-05 00:56:16 -04:00
Skip import of current calendar on error
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
576e4e8f2a
commit
e4f1d4192a
1 changed files with 18 additions and 10 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue