Skip to content

Commit 2989d0f

Browse files
committed
Skip import of current calendar on error
Signed-off-by: Christopher Ng <[email protected]>
1 parent c407bb9 commit 2989d0f

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

apps/dav/lib/UserMigration/CalendarMigrator.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ private function initCalendarObject(): VCalendar {
318318
return $vCalendarObject;
319319
}
320320

321+
/**
322+
* @throws InvalidCalendarException
323+
*/
321324
private function importCalendarObject(int $calendarId, VCalendar $vCalendarObject, OutputInterface $output): void {
322325
try {
323326
$this->calDavBackend->createCalendarObject(
@@ -330,11 +333,12 @@ private function importCalendarObject(int $calendarId, VCalendar $vCalendarObjec
330333
// Rollback creation of calendar on error
331334
$output->writeln('Error creating calendar object, rolling back creation of calendar…');
332335
$this->calDavBackend->deleteCalendar($calendarId, true);
336+
throw new InvalidCalendarException();
333337
}
334338
}
335339

336340
/**
337-
* @throws CalendarMigratorException
341+
* @throws InvalidCalendarException
338342
*/
339343
private function importCalendar(IUser $user, string $filename, string $initialCalendarUri, VCalendar $vCalendar, OutputInterface $output): void {
340344
$principalUri = $this->getPrincipalUri($user);
@@ -446,15 +450,19 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
446450
}
447451
[$initialCalendarUri, $suffix] = $splitFilename;
448452

449-
$this->importCalendar(
450-
$user,
451-
$filename,
452-
$initialCalendarUri,
453-
$vCalendar,
454-
$output,
455-
);
456-
457-
$vCalendar->destroy();
453+
try {
454+
$this->importCalendar(
455+
$user,
456+
$filename,
457+
$initialCalendarUri,
458+
$vCalendar,
459+
$output,
460+
);
461+
} catch (InvalidCalendarException $e) {
462+
// Allow this exception to skip failed calendar import
463+
} finally {
464+
$vCalendar->destroy();
465+
}
458466
}
459467
}
460468
}

0 commit comments

Comments
 (0)